Page 1 of 1

delete on condition

Posted: 19 Aug 2013 08:57
by glob5
looking for a script that only checks a folder and in the folder if, there is only one folder that starts with "abc_cdf" exits. If there are more than one folder starting with "abc_cdf", delete the ones that are older than 5 days. This script does not go inside the sub folders. It is not recursive.

Re: delete on condition

Posted: 19 Aug 2013 09:18
by foxidrive
How much of the script have you written? :)

Re: delete on condition

Posted: 20 Aug 2013 00:12
by glob5
popular common easy stuff but not enough.:
for /f "delims=*" %%x in ('dir /b /ad-s-h C:\dirx\abc_cdf*') do rd "%%x" /s /q

Re: delete on condition

Posted: 20 Aug 2013 00:45
by foxidrive
Look into forfiles.exe as it can handle a range of days old and is native to Vista and higher.

xxcopy also has good date handling capability, and is free for personal use.

Re: delete on condition

Posted: 20 Aug 2013 14:36
by penpen
Aditionally maybe this thread helps you:
http://www.dostips.com/forum/viewtopic.php?f=3&t=4846

penpen