Solved

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

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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