Solved

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

Posted on 2006-07-14
3
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

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…
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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