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.
.bat script for latest file
Name: Ravi_varma Date: June 12, 2008 at 02:11:24 Pacific OS: xp CPU/Ram: amd Product: 2004
Comment:
i have .csv files with timestamps in a folder lke below.
I need to keep only the latest file and delete rest of the files in that folder...in this case i want to keep only 20080302172309.csv file and delete remaing.
Please suggest how can i do it in batch scripting which needs to be executed in windows
Name: klint Date: June 12, 2008 at 02:54:13 Pacific
Reply:
@echo off setlocal enabledelayedexpansion set latest_skipped= for /f "delims=" %%a in ('dir /b /a-d /o-n 20*.csv') do ( if defined latest_skipped ( del %%a ) else ( set latest_skipped=1 ) )
0
Response Number 2
Name: Mechanix2Go Date: June 12, 2008 at 03:01:43 Pacific
Reply:
not tested
::== keeplast
@echo off setLocal EnableDelayedExpansion
for /f "skip=1 tokens=* delims= " %%a in ('dir/b/o-n *.csv') do ( del %%a )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 3
Name: klint Date: June 12, 2008 at 03:53:50 Pacific
Reply:
Good one, M2, I forgot about the usefulness of the "skip" keyword.
Summary: I have a directory with files that all have a prefix where I need to have a cmd or bat script to remove the prefix for all files in the directory. I know how to write a script that renames the files t...
Summary: Hello, I need to remove some information from textpad containing numbers and address(s). In the example, someone sends me information that contains people information with numbers starting. If I did a...
Summary: Is there any batch or any script which will help sent a file from my pc to user end pc over the nt. for ex. I have to update a user pc everytime there is any new pc added in this one deprtment. I woul...