Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming files daily

Status
Not open for further replies.

MooSki

Programmer
Jun 13, 2002
22
GB
Hi guys,

I've got a reporting tool that exports to an Excel file. This file is produced everyday, but I would like it to have a suffix of the date it was produced.

eg ExportFile130602.xls

The reporting software (Cognos) doesn't seem to have this capability and I was going to just schedule a batch file to do this every day.

Does anyone know how to put the date suffix on a file name?

Any help would be greatly appreciated.

Thanks in advance.
MooSki
 
This is how I did it in my own coding - there may be an easier way, but I did this on my own:

Dim Today

' In the form of mm/dd/yyyy
Today = IIf(DatePart(&quot;m&quot;, Date) < 10, &quot;0&quot; & DatePart(&quot;m&quot;, Date), DatePart(&quot;m&quot;, Date)) & IIf(DatePart(&quot;d&quot;, Date) < 10, &quot;0&quot; & DatePart(&quot;d&quot;, Date), DatePart(&quot;d&quot;, Date)) & DatePart(&quot;yyyy&quot;, Now())

FileCopy &quot;C:\Temp\NameOfFile.Txt&quot;,&quot;C:\Temp\NameOfFile&quot; _
& Today & &quot;.txt&quot;
Kill &quot;C:\Temp\NameOfFile.Txt&quot;

HTH
Roy
aka BanditWk
Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)
 
Thanks Bandit. I'll try this out and get back to you.

Mooski
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top