my bat file has these two for loops for copying files and moving folders. Need to modify them
to rename files and folders that already exist in the destination with a time stamp before copying and moving the sources.
for /f "tokens=* delims= " %%f in ('dir/s/b dira\*.bin ^|find /v "DDD"') do (copy "%%f" dirb)
for /f %%d in ('dir /b /ad "dirC"') do (move /y dir1\%%d dirD)
rename
Moderator: DosItHelp
Re: rename
my bat file has these two for loops for copying files and moving folders. Need to modify them
to rename files and folders that already exist in the destination with a time stamp before copying and moving the sources.
for /f "tokens=* delims= " %%f in ('dir/s/b dira\*.bin ^|find /v "DDD"') do (copy "%%f" dirb)
for /f %%d in ('dir /b /ad "dirC"') do (move /y dirC\%%d dirD)
to rename files and folders that already exist in the destination with a time stamp before copying and moving the sources.
for /f "tokens=* delims= " %%f in ('dir/s/b dira\*.bin ^|find /v "DDD"') do (copy "%%f" dirb)
for /f %%d in ('dir /b /ad "dirC"') do (move /y dirC\%%d dirD)
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: rename
I think this should do it:
Code: Select all
for /f "tokens=* delims= " %%f in ('dir/s/b dira\*.bin ^|find /v "DDD"') do (
if exist %%f rename %%f %%f%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%
copy "%%f" dirb
)
for /f %%d in ('dir /b /ad "dirC"') do (
if exist %%d rename %%d %%d%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%
move /y dirC\%%d dirD
)