Solved

Rename Command stopped working in Batch File

Posted on 2013-01-25
1
532 Views
Last Modified: 2013-01-25
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
Comment
Question by:eddiepardon
1 Comment
 

Accepted Solution

by:
eddiepardon earned 0 total points
Comment Utility
I found the problem... someway an extra % was added before the .txt
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now