Delete 300000 below value number txt files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Delete 300000 below value number txt files

#1 Post by mohdfraz » 21 Aug 2012 04:02

Hi,

I have files like this;
-7237435.txt
223435.txt
23435.txt
-33415.txt
323435.txt
etc

I need a batch file which can delete below 300000 number txt files and keep 300000 higher number files only. In this case keep only 323435.txt only and delete rest all files.

Thanks you

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Delete 300000 below value number txt files

#2 Post by foxidrive » 21 Aug 2012 04:20

This is untested and assumes that all .txt files have numbers for names and that none exceed 2^31

Code: Select all

@echo off
for %%a in (*.txt) do if %%~na LSS 300000 del "%%a"

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Delete 300000 below value number txt files

#3 Post by mohdfraz » 21 Aug 2012 04:54

foxidrive wrote:This is untested and assumes that all .txt files have numbers for names and that none exceed 2^31

Code: Select all

@echo off
for %%a in (*.txt) do if %%~na LSS 300000 del "%%a"


:) Awesome many thanks worked like a charm

Post Reply