Automated rename not working

I have an old server that has had a backup hardware failure. The server is going to be replaced. Instead of getting a new tape drive and tapes, portable hard drives were purchased to use for backing up. The server has USB 1 on it and the backups were terribly slow. I connected the drive to a workstation and this improved the speed but not enough. I am sending the backup to a workstation and I have a backup routine to move the files from the workstation to the portable hard drive. All of this works fine but I am trying to rename the backup folder to a name with the date and time using a batch file to accomplish all of this. The only snag in this is the rename. I tested the batch file in my office and it works fine but at my customers I get a syntax error. This is the command:

ren e:\Backup-to-disk %date:~-10,2%"-"%date:~-7,2%"-"%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%

What is going wrong?
Who is Participating?
jbcbussoftAuthor Commented:
I have removed the time portion of the string and I no longer am getting an error. Since I don't need the time I have removed this from the string thus resolving the problem.
MAS (MVE)Technical Department HeadCommented:
first you try to get the date format by running "echo %date%"
then change accordingly.

If you dont know please let me know the result you get when running "echo %date%" and let me know what is the name format you required
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Depending on the date format used in Windows, the result should be
but everything should be in one pair of double quotes or none.
ren e:\Backup-to-disk %date:~-10,2%-%date:~-7,2%-%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%

Open in new window

However, I cannot see why you should get a syntax error.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

jbcbussoftAuthor Commented:
MAS, I will have access to the computer after 4:30 CDT. I will report the results then.

Olemo, "However, I cannot see why you should get a syntax error." Agreed! I tried this on my pc first with no problems. I wanted some fresh eyes on this since I was seeing no problem.
jbcbussoftAuthor Commented:
That isn't what I did. I split the points 3 ways even though I solved my own problem.
jbcbussoftAuthor Commented:
Thanks for the input!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.