Question : Need a batch file to copy files in a folder and append the date and time

Need a batch file that will copy files in a folder (c:\folder1) to another folder (c:\folder2) and append the date and time to the filename.  So if the source files were c:\folder1\file1.txt and c:\folder1\file2.txt it would copy them to c:\folder2\file1datetime.txt c:\folder2\file2datetime.txt

Thanks

Answer : Need a batch file to copy files in a folder and append the date and time

Sorry about that.

I've fixed it up now.  Hopefully the code is understandable.

Mine will do recurse subdirectories and keeps the folder structure to the destination.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
SETLOCAL ENABLEDELAYEDEXPANSION
Set Folder1=C:\Folder1
Set Folder2=C:\Folder2
Set Extensions=*.*
 
Set DateNow=%Date:~-10%
Set DateNow=%Date:/=-%
Set TimeNow=%Time:~0,-3%
Set TimeNow=%TimeNow: =0%
Set TimeNow=%TimeNow::=.%
 
for /r "%Folder1%" %%a in (%Extensions%) do (
    Set Dest=%%~dpna!DateNow!!TimeNow!%%~xa
    Set Dest=!Dest:%Folder1%=%Folder2%!
    ECHO f|XCOPY "%%a" "!Dest!"
)
Open in New Window Select All
Random Solutions  
 
programming4us programming4us