Solved

Batch file to rename a file with the current date in the filename.

Posted on 2006-07-14
3
392 Views
Last Modified: 2010-04-13
I am looking for an example of how to write a batch file that will rename an Excel worksheet file with the current date as part of the file's name.  For example 'Open Items 07-14-06.xls'.  

Any help will be greatly appreciated.  Thanks.
0
Comment
Question by:dc900
3 Comments
 
LVL 3

Accepted Solution

by:
danishtahir earned 300 total points
ID: 17113070
Lets say your current Excel file is call excelfile.xls

Following line in your batch file will allow you to rename it according to current date:

ren excelfile.xls "Open Items %date:~4,2%-%date:~7,2%-%date:~-2%.xls"

0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 50 total points
ID: 17113434
I know this isn't specifically what you ask for but if you are producing this in Excel anyway I'd add a macro in excel which does this:

sub Save()
  activeworkbook.SaveAs("Open Items " & date$ & ".xls")
end sub

To do that

Alt F11 into the VBA editor.  Insert  |module, Past above code in.  Now go to Tools | Macro | Macros click on Options and give it a shortcut key, e.g. Control Shift S.  Then when you press Control Shift S the file is saved with the date as the name...  You can also link a macro to a button etc.

Steve
0
 
LVL 9

Expert Comment

by:vsg375
ID: 17113870
the above experts have a good point, but imho, this solution is a bit easier :o)

http://www.informatics-consulting.ch/software/namedate.htm

HTH
Cheers
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exchange server 2003 sp2 local queue frozen mail 3 363
windows 2000 3 429
Sapphire RAGE 128 Pro 32M - Windows 2000 Driver 2 930
Windows Foriegn Disk 3 135
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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