Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

dos batch files

Thread Tools
 
Search this Thread
 
Old 31 July 2003, 04:33 PM
  #1  
beemerboy
Scooby Regular
Thread Starter
 
beemerboy's Avatar
 
Join Date: Sep 2002
Location: Essexville
Posts: 4,391
Likes: 0
Received 0 Likes on 0 Posts
Post

hi folks,
can someone help me with a batch file, that renames a file and datestamps it.
ie a .log file and renames to 25_06_03.log

or something like that

using the rename command line ...

then i can schedule it from there..

??

cheers in advance

BB
Old 31 July 2003, 06:32 PM
  #2  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Thumbs up

Think I wrote something like that at one of my old companies. Thank god for backup CDs! (but the CD is at work!)

I'll dig it out tomorrow for you mate

Rich
Old 01 August 2003, 12:27 AM
  #3  
Bullring
Scooby Regular
 
Bullring's Avatar
 
Join Date: Jul 2003
Location: www.irally.net
Posts: 253
Likes: 0
Received 0 Likes on 0 Posts
Post

Try this - it may not be pretty but it works

set d1=%date%
set dd=%d1:~4,2%_
set mm=%d1:~7,2%_
set yy=%d1:~12,2%
set fd=%dd%%mm%%yy%.txt
ren test.txt %fd%
Old 01 August 2003, 07:40 AM
  #4  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Wink

pretty much the same as the version I had:

set mydate=%date%
set dd=%mydate:~0,2%_
set mm=%mydate:~3,2%_
set yy=%mydate:~6,4%
set newname=%dd%%mm%%yy%.log
ren sqllog.log %newname%

I guess t all depends on how your server is set up to handle dates!
Old 01 August 2003, 09:24 AM
  #5  
Bullring
Scooby Regular
 
Bullring's Avatar
 
Join Date: Jul 2003
Location: www.irally.net
Posts: 253
Likes: 0
Received 0 Likes on 0 Posts
Wink

So it's true! Great minds do think alike ;-)
Old 02 August 2003, 09:07 AM
  #6  
beemerboy
Scooby Regular
Thread Starter
 
beemerboy's Avatar
 
Join Date: Sep 2002
Location: Essexville
Posts: 4,391
Likes: 0
Received 0 Likes on 0 Posts
Post

thanks a lot guys, you are most kind.

BB
Old 02 August 2003, 03:05 PM
  #7  
nigelward
Scooby Regular
 
nigelward's Avatar
 
Join Date: Oct 2001
Posts: 831
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

This will also do it :

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do ren test.txt %%i_%%j_%%k.log
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
blackieblob
ScoobyNet General
4
01 October 2015 11:37 AM
yabbadoo4
ScoobyNet General
11
30 September 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: dos batch files



All times are GMT +1. The time now is 11:58 AM.