Solved

Rename Command stopped working in Batch File

Posted on 2013-01-25
1
550 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

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

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…
Suggested Courses

635 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