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 Jul 31, 2003 | 04:33 PM
  #1  
beemerboy's Avatar
beemerboy
Thread Starter
Scooby Regular
 
Joined: Sep 2002
Posts: 4,391
Likes: 0
From: Essexville
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
Reply
Old Jul 31, 2003 | 06:32 PM
  #2  
SJ_Skyline's Avatar
SJ_Skyline
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
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
Reply
Old Aug 1, 2003 | 12:27 AM
  #3  
Bullring's Avatar
Bullring
Scooby Regular
 
Joined: Jul 2003
Posts: 253
Likes: 0
From: www.irally.net
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%
Reply
Old Aug 1, 2003 | 07:40 AM
  #4  
SJ_Skyline's Avatar
SJ_Skyline
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
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!
Reply
Old Aug 1, 2003 | 09:24 AM
  #5  
Bullring's Avatar
Bullring
Scooby Regular
 
Joined: Jul 2003
Posts: 253
Likes: 0
From: www.irally.net
Wink

So it's true! Great minds do think alike ;-)
Reply
Old Aug 2, 2003 | 09:07 AM
  #6  
beemerboy's Avatar
beemerboy
Thread Starter
Scooby Regular
 
Joined: Sep 2002
Posts: 4,391
Likes: 0
From: Essexville
Post

thanks a lot guys, you are most kind.

BB
Reply
Old Aug 2, 2003 | 03:05 PM
  #7  
nigelward's Avatar
nigelward
Scooby Regular
 
Joined: Oct 2001
Posts: 831
Likes: 0
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
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
blackieblob
ScoobyNet General
4
Oct 1, 2015 11:37 AM
yabbadoo4
ScoobyNet General
11
Sep 30, 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
Sep 26, 2015 08:00 AM
Littleted
Computer & Technology Related
0
Sep 25, 2015 08:44 AM




All times are GMT +1. The time now is 03:06 AM.