Solved

Renaming an excel file

Posted on 2013-11-25
2
308 Views
Last Modified: 2013-11-25
I want to rename a file with date and time stamp, however this seems to be the incorrect syntax.  The computer it's running on is Windows 7, 32bit.

ren new.xls newfile_%time:~0,2%%time:~3,2%-%date:~-10,2%%date:~3,2%%date:~-4,4%.xls

Open in new window

0
Comment
Question by:100questions
2 Comments
 
LVL 30

Accepted Solution

by:
IanTh earned 500 total points
ID: 39675837
0
 
LVL 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 39676087
Keep in mind that the %date% environment variable returns the current date using the Windows setting for Short Date Format. The problem is likely because your year/month/day offsets in the Rename command don't match those in the Short Date Format. You can change the Short Date Format via:

Control Panel
Region and Language
Formats

Select whatever format you want and then change the Rename command accordingly. For example, if you select yyyy-MM-dd, then here's the command for appending mmddyyyy:

ren new.xls newfile_%time:~0,2%%time:~3,2%-%date:~5,2%%date:~8,2%%date:~0,4%.xls

Of course, put in hyphens or underscores wherever else you want them. Regards, Joe
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
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…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
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…

713 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