Solved

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

Posted on 2006-07-14
3
382 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

15 Experts available now in Live!

Get 1:1 Help Now