Solved

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

Posted on 2006-07-14
3
368 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now