Delete 2 of every 3 similarly named files via batch script --
Posted on 2011-02-23
I have a directory of files, such as:
N:\SP\Fri 02112011- 00435.52mysqldmp.ra
N:\SP\Fri 02112011- 80631.90mysqldmp.ra
N:\SP\Sat 02122011- 00434.32mysqldmp.ra
N:\SP\Sat 02122011- 80639.59mysqldmp.ra
N:\SP\Sun 02132011- 00426.79mysqldmp.ra
N:\SP\Sun 02132011- 00428.52mysqldmp.ra
N:\SP\Sun 02132011- 80631.80mysqldmp.ra
I would like to be able to have a script that deleted 2 of the 3 02132011 files, etc. It should always keep either the first, or the last of the 3 files for consistency, but I don't much care which.
It should give me a sample output of files to be deleted: i.e.
1) determine files to be deleted
2) copy these to a text file
3) pause, waiting for me to read/check the file
4) proceed to delete.
If there are 2 files that fit the pattern, it should only delete one. If there is only 1 file, it should not touch it.