Here's the issue: I run a simple batch file to make some critical backups of mainly text and zip files. The script works well and makes the backups to a folder that is named for the day-month-year-time; so the created folder (for example) will be named something like this: 07-31-2014-15.16. This gives me a unique folder for every backup that I create.
But I keep running into the darn blank line problem when I do the backup before 10 a.m., as Windows sees the leading blank space as an invalid character. For instance, if I run the backup at 9:37 a.m., the batch file wants to create the folder like this: 07-31-2014- 9.37. And the script fails to create the backed up files and folders because of the space before the 9.
I think there is a way to use the "WMIC OS Get LocalDateTime" method to solve this problem, but I just can't get it to work. If it helps, here is the complete script that I run:
Code: Select all
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%C
set DateMonth=%%B
set DateYear=%%D
)
for /F "tokens=1-4 delims=/ " %%F in ('time/t') do (
set DateTime=%%F
)
set CurrentDate=%DateMonth%-%DateDay%-%DateYear%-%time:~0,2%.%time:~3,2%
xcopy c:\1DOS\factory c:\zBackup\%CurrentDate%\Boxes_and_Pfiles\ /s >> c:\log.txt
xcopy x:\Emulators\DosBox\dosroot\apba\apba20\BB\GAME\2014.ddr c:\zBackup\%CurrentDate%\Statmaster_Org\ /s /t
xcopy x:\Emulators\DosBox\dosroot\apba\apba20\BB\GAME\2014.ddr\SMO00003.T13\*.* c:\zBackup\%CurrentDate%\Statmaster_Org\SMO00003.T13\ >> c:\log.txt
Xcopy c:\1DOS\special\score.txt c:\zBackup\%CurrentDate%\ >> c:\log.txt
mkdir c:\zBackup\%CurrentDate%\Game_Summaries
xcopy c:\apbaz\2014\games\al_sum.txt c:\zBackup\%CurrentDate%\Game_Summaries\ >> c:\log.txt
xcopy c:\apbaz\2014\games\nl_sum.txt c:\zBackup\%CurrentDate%\Game_Summaries\ >> c:\log.txt
ren c:\zBackup\%CurrentDate%\score.txt %CurrentDate%_Results.txt
move c:\log.txt c:\zBackup\%CurrentDate%\
ren c:\zBackup\%CurrentDate%\log.txt %CurrentDate%_Log.txt
Any help would be sincerely appreciated. Again, the script works well, just not between the hours of 1 and 10 a.m.
MOD EDIT: added code tags