Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 560
  • Last Modified:

Rename Command stopped working in Batch File

Hello Experts,

I have a batch file that has been working until today.
For some reason these 2 lines of code below are no longer working.

rename SR1171_Sync_Files.txt SR1171_Sync_Files_%date:~4,2%-%date:~7,2%-%date:~10,4%_At_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.txt
rename SR1171_Sync_Files_Log.txt SR1171_Sync_Files_Log_%date:~4,2%-%date:~7,2%-%date:~10,4%_At_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.txt

If I run them from the command line they work just fine.

What could be causing this problem?

Below is the complete batch file, I did remove some of the code that is not related to the issue:

cd C:\Users\pardone\Desktop\SR\Upload Files To SharePoint
setlocal
set MyLogFile=SR1171_Sync_Files.txt

echo %Date% %time%
@echo on
echo ==================================================:  %Date% %time% >> %MyLogFile%

echo Sync_Files Started: %Date% %time% >> %MyLogFile%

rem change the following line as needed to point to source and dest paths and log file name

:: Some code for robocopy Code removed

call :REPORT_ERRORLEVEL

:REPORT_ERRORLEVEL
if errorlevel 16 echo Error Level 16 ***FATAL ERROR*** >> %MyLogFile% & call :END
if errorlevel 15 echo Error Level 15 OKCOPY + FAIL + MISMATCHES + XTRA >> %MyLogFile% & call :END
if errorlevel 14 echo Error Level 14 FAIL + MISMATCHES + XTRA >> %MyLogFile% & call :END
if errorlevel 13 echo Error Level 13 OKCOPY + FAIL + MISMATCHES >> %MyLogFile% & call :END
if errorlevel 12 echo Error Level 12 FAIL + MISMATCHES >> %MyLogFile% & call :END
if errorlevel 11 echo Error Level 11 OKCOPY + FAIL + XTRA >> %MyLogFile% & call :END
if errorlevel 10 echo Error Level 10 FAIL + XTRA >> %MyLogFile% & call :END
if errorlevel 9 echo Error Level 9 OKCOPY + FAIL >> %MyLogFile% & call :END
if errorlevel 8 echo Error Level 8 FAIL >> %MyLogFile% & call :END
if errorlevel 7 echo Error Level 7 OKCOPY + MISMATCHES + XTRA >> %MyLogFile% & call :END
if errorlevel 6 echo Error Level 6 MISMATCHES + XTRA >> %MyLogFile% & call :END
if errorlevel 5 echo Error Level 5 OKCOPY + MISMATCHES >> %MyLogFile% & call :END
if errorlevel 4 echo Error Level 4 MISMATCHES >> %MyLogFile% & call :END
if errorlevel 3 echo Error Level 3 OKCOPY + XTRA >> %MyLogFile% & call :END
if errorlevel 2 echo Error Level 2 XTRA >> %MyLogFile% & call :END
if errorlevel 1 echo Error Level 1 OKCOPY >> %MyLogFile% & call :END
if errorlevel 0 echo Error Level 0 No Change >> %MyLogFile% & call :END

:END
echo Sync_Files Finished: %Date% %time% >> %MyLogFile%

echo ==================================================:  %Date% %time% >> %MyLogFile%
rename SR1171_Sync_Files.txt SR1171_Sync_Files_%date:~4,2%-%date:~7,2%-%date:~10,4%_At_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.txt
rename SR1171_Sync_Files_Log.txt SR1171_Sync_Files_Log_%date:~4,2%-%date:~7,2%-%date:~10,4%_At_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.txt
0
eddiepardon
Asked:
eddiepardon
1 Solution
 
eddiepardonAuthor Commented:
I found the problem... someway an extra % was added before the .txt
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Tackle projects and never again get stuck behind a technical roadblock.
Join Now