Solved

Renaming an excel file

Posted on 2013-11-25
2
304 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 52

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
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…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

777 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