Solved

Rename Command stopped working in Batch File

Posted on 2013-01-25
1
546 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query performance - SQL Server 20 85
wordpress limitations 4 147
Check Disk (CHKDSK) on all volumes and fix if needed. 8 223
Authentication of Web Services 3 111
Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
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…

734 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