Batch file find size and delete or move to temp.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rajeshcr2000
Posts: 1
Joined: 21 Aug 2012 12:08

Batch file find size and delete or move to temp.

#1 Post by rajeshcr2000 » 21 Aug 2012 12:21

Hi,
I am very new to batch file scripting :-)

Need help to create the batch file for finding the size and based on the condition the file shluld be deleted or moved to temp location.

Thanks
-Raj

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Batch file find size and delete or move to temp.

#2 Post by Squashman » 21 Aug 2012 12:30

Code: Select all

for /f "delims=" %%G in ('dir /a-d /b *.txt') do (
   IF %%~zG GEQ 100000 (
      del "%%G"
   ) else (
      move "%%G" C:\temp
   )
)

Post Reply