Computing.Net > Forums > Programming > Batch: Find newest *.zip in dir

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch: Find newest *.zip in dir

Reply to Message Icon

Name: srade
Date: October 3, 2005 at 18:59:22 Pacific
OS: Windows XP Professional
CPU/Ram: Sempron 2500+ / 512MB
Comment:

I tried to find something on the internet, but i came up empty handed. I need some batch scripting help.
This is the situation:
I have *.zip files in a directory, i need to find the newest file and do a command and delete the rest.

i can get the list: dir /b /O:-d >> list.dat
newest file is first. but how to process it this list?

Oh and it must be compatible with windows 9x/me and nt/xp versions, or as much as possible



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: October 8, 2005 at 12:06:47 Pacific
Reply:

Hi
This would work for both systems if you use the program Change.com program from PC Magazine.
It works in XP,DOS and Win9?.
What you want is easy in XP, but not Win9?.
If you can't find it, I will EMail it to you.

--------------------------
CHANGE
Michael J. Mefford
Purpose Performs a rapid search-and-replace operation for text
strings and/or ASCII decimal codes throughout a file of
maximum 40,000-byte length.

Format
CHANGE filespec findstring replacestring

Examples
CHANGE NOGOSSIP.ART "Miss Jones" "Mrs. Smith"
CHANGE \COMM\MCI.B16 13,10 ""
-----

@echo off
dir *.zip /b /o-d > File1.txt
find /n /v "" File1.txt > File2.txt
change File2.txt "[1]" "set Latest=" > nul
type File2.txt | find "set" > Latest.bat
call Latest.bat
echo Latest=%Latest%
ren %Latest% Latest.bak
if exist *.zip del *.zip
ren Latest.bak %Latest%
del File?.txt
del Latest.bat


0

Response Number 2
Name: Mechanix2Go
Date: October 9, 2005 at 01:57:33 Pacific
Reply:

dt10,

Kewl


If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: dtech10
Date: October 9, 2005 at 06:36:52 Pacific
Reply:

Hi Mechanix
From you that's a really a compliment.
Thanks



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch: Find newest *.zip in dir

Batch file to find newest files www.computing.net/answers/programming/batch-file-to-find-newest-files/16808.html

batch to count files in DIR then send email www.computing.net/answers/programming/batch-to-count-files-in-dir-then-send-email/19628.html

Find latest JRE in batch file www.computing.net/answers/programming/find-latest-jre-in-batch-file/15516.html