Orchard
asked on
Need to Copy a folder to a new location and append copied folder with date and time
Hi, I need some help please
I have a requirement to copy a folder "folderA" to a new location and append the copied folder with the date and time ie "folderA_date_time" from within a batch file.
Any help greatly appreciated.
Many thanks
I have a requirement to copy a folder "folderA" to a new location and append the copied folder with the date and time ie "folderA_date_time" from within a batch file.
Any help greatly appreciated.
Many thanks
ASKER
Hi Knight
the result is
05/05/2011 16:33:32:01
the result is
05/05/2011 16:33:32:01
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
unfortunately there is a bit of ambiguity in todays date - 05/05/2011. Is that MM/DD/YYYY or is it DD/MM/YYYY ... and which way do you want it in the folder name?
(personally I recommend YYYYMMDD for sorting purposes)
ASKER
Yes I agree YYYYMMDD would be great
well, if your system date format is MM/DD/YYYY then use this:
set NEWFOLDERNAME = "folderA_%date:~6,4%%date: ~0,2%%date :~3,2%_%ti me:~0,2%%t ime:~3,2%% time:~6,2% "
but if your system date format is DD/MM/YYYY then use this:
set NEWFOLDERNAME = "folderA_%date:~6,4%%date: ~3,2%%date :~0,2%_%ti me:~0,2%%t ime:~3,2%% time:~6,2% "
set NEWFOLDERNAME = "folderA_%date:~6,4%%date:
but if your system date format is DD/MM/YYYY then use this:
set NEWFOLDERNAME = "folderA_%date:~6,4%%date:
(I mean use that line in the script posted above)
ASKER
Hi Knight
I had to remove the spaces before and after the = in the set NEWFOLDERNAME line, but other than that it works a dream
Many thanks
I had to remove the spaces before and after the = in the set NEWFOLDERNAME line, but other than that it works a dream
Many thanks
Good catch on the spaces! That one gets me every time. Glad it works!
echo %date% %time%