|
Answer» Hi, i'm new and need help writing a batch file.
I need to copy all .log files from one directory to another, but only the files that have been modified on that date i.e today.
thanks for help
PS i have never wrote any DOS files before
Not surehow to do exactly that, but you could use the archive bit to the same effect.
xcopy c:\*.log c:\destination\*.log /a attrib c:\*.log -a
This will copy the files then remove the archive bit. When you run the batch file again it will only copy the files which have been created or modified since the last time it was run. If it is run once a day then it will do what you want.thanks. but i need it just to be log files and them to just be from 'today'
:-/The xcopy COMMAND provides a date switch which allows to select the files to be copied according to their date (switch /D). The problem is to pass "today" to the switch. On Windows XP and Windows 2000 there is a possibility to extract the current date. The format the date is displayed in MS-DOS depends on the regional SETTINGS of your computer. If the following command results in a date like:
Code: [Select]C:\> echo %DATE% 31.01.2005 you can extract day, MONTH and year of "today" with the following code and call xcopy:
Code: [Select]set d=%DATE:~0,2% set m=%DATE:~3,2% set y=%DATE:~6,4% xcopy *.log dest /d:%m%-%d%-%y% dest is the destination folder.
Have FUN, [glb]cs[/glb]that was a big help thanks mate
|