batch script to pick thelatest file
|
Original Message
|
Name: shalini.das
Date: April 24, 2008 at 11:40:23 Pacific
Subject: batch script to pick thelatest fileOS: windows xpCPU/Ram: Pentium Dual Core / 2 GbModel/Manufacturer: Shuttle |
Comment: HI All, I am new to batch scripting and this is my first script pls help me out. I have to right a batch script, which has to pick the latest file in my directory in which file name are as below, filename_2007-12-23.txt filename_2007-12-30.txt filename_2008-01-06.txt after picking the latest file it has to rename the latest file as below. filename_20071223.txt filename_20071230.txt filename_20080106.txt Please suggest me how i can do this. Best Regards, Shalini
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mechanix2Go
Date: April 24, 2008 at 20:45:46 Pacific
|
Reply: (edit)@echo off setLocal EnableDelayedExpansion for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d c:\files\*.txt') do ( set latest=%%a & goto :done ) :done echo latest is !latest! ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: shalini.das
Date: April 25, 2008 at 02:25:26 Pacific
|
Reply: (edit)HI, Thanks a lot for the script, i tried it on ms- dos .bat file, but it was not picking and renaming any file. Pls tell me how can i do this. Best regards, Shalini
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Mechanix2Go
Date: April 25, 2008 at 03:51:10 Pacific
|
Reply: (edit)I though we were talking about XP. It will take much more work in DOS. What version are you using? ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: