Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi experts out there,
I would like to use to BAT files to copy all newly modified files from a source folder to a destination folder. Inside the source folder itself consists of subfolders. What I want to copy is just the newly modified files but I code below copies the folder too. What kind of amendments I need to make so that it won't copy the folders. Thanks._________________________________________
@echo off
C:\DOS\XSET CUR-DATE DATE MM-DD-YY
IF "%1" == "" GOTO LIST-CUR
IF "%1" == "\" GOTO LIST-ALL:LIST-CUR
DIR *.* /O:N | Find "%CUR-DATE%" | xcopy c:\testsource\*.txt c:\testdigi\ /m /e /y
GOTO END:LIST-ALL
DIR \*.* /O:N /S | Find "%CUR-DATE%" | xcopy c:\testsource\*.txt c:\testdigi\ /m /e /y:END
SET CUR-DATE=

javensoong, perhaps I'm mistaken, been a while, but seems to me that "IF "%1" == "\" GOTO LIST-ALL" should be "IF "%1" == "\" GOTO END"??? The first version tells it to copy the entire thing if there aren't changes.
HTH.
Ed in Texas.

Hi Ed, Thanks for ur reply
From what I understand, IF "%1" == "\" GOTO LIST-ALL will ask it to go to
:LIST-ALL
DIR \*.* /O:N /S | Find "%CUR-DATE%" | xcopy c:\testsource\*.txt c:\testdigi\ /m /e /yANyway, the copying part is ok. The problem is that if there are txt files in subfolders, I only want to copy the txt files to the destination table instead of the folders. Any idea on that?

javensoong, sadly, no specifics to offer. Seems to me you should be able to use 'if'or 'if then - else' statements to pinpoint what you want.
HTH.
Ed in Texas.

Appreciated ur reply. Does that mean I need to loop through each folder to copy those txt files from there?

![]() |
windows could not start b...
|
Data validation code(exce...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |