PC Review


Reply
Thread Tools Rate Thread

Batch file to rename with time and date

 
 
alexanderd79@googlemail.com
Guest
Posts: n/a
 
      23rd Nov 2007
Hi

I have a batch file that renames a file and appends the time on the
end of the filename. What I need it to do is append both the time and
date at the same time. My line of code is:

for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename
"filename.xls" "filename"%%d-%%e-%%f.xls

I'm sure i can do this in one line but not sure how to add the %date%
in correctly

Any help appreciated

Thanks
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      23rd Nov 2007

<(E-Mail Removed)> wrote in message
news:ca05d8ad-d2ab-4099-b622-(E-Mail Removed)...
> Hi
>
> I have a batch file that renames a file and appends the time on the
> end of the filename. What I need it to do is append both the time and
> date at the same time. My line of code is:
>
> for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename
> "filename.xls" "filename"%%d-%%e-%%f.xls
>
> I'm sure i can do this in one line but not sure how to add the %date%
> in correctly
>
> Any help appreciated
>
> Thanks


Perhaps something like this:
for /F "tokens=1-8 delims=:/" %%a in ('echo %date% %time%') do echo ren
"file.xls" "%%a-%%b-%%c %%d-%%e file.xls"


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rename csv file by removing date/time stamp before importing fishy Microsoft Access Form Coding 7 16th Apr 2010 08:20 AM
Batch File Rename + Date added & Move to another location carla_cund@hotmail.com Microsoft Windows 2000 CMD Promt 19 19th Jan 2007 08:51 AM
BATCH: generate file names using system date & time? K. Shier Microsoft Windows 2000 CMD Promt 12 17th Oct 2003 04:54 PM
Re: rename file in batch with date in file name guard Microsoft Windows 2000 CMD Promt 0 16th Sep 2003 11:01 PM
Re: rename file in batch with date in file name guard Microsoft Windows 2000 New Users 0 16th Sep 2003 11:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:19 PM.