corpkid
asked on
How do I delete files that DO NOT have the "A" (archive) attribute set via a batch/script?
This should be pretty easy (or so I think). How can I (via a batch file) delete all files that do NOT have the A (archive) attribute set (including subdirectories)?
Long story short, once our backup files are shipped to tape, the A attribute is cleared by the backup software. However these (really big) files are not removed. I want to run a script each night that cleans up files that have already been shipped (and thus do NOT have the A attribute set).
Thanks!
Dominic
Long story short, once our backup files are shipped to tape, the A attribute is cleared by the backup software. However these (really big) files are not removed. I want to run a script each night that cleans up files that have already been shipped (and thus do NOT have the A attribute set).
Thanks!
Dominic
ASKER
Hey Sirbounty - thanks for the help. That got me close, but the output file (deletionlist.txt) is formated like such:
03/18/2007 11:08 PM 7,644 DATA_BACKUP4_log_200703182 100.txt
As such, the 2nd part of the script barks the following errors:
c:\erase 03/18/2007
Invalid switch - "18"
I don't know how to change the output...
Thanks again! :)
Dominic
03/18/2007 11:08 PM 7,644 DATA_BACKUP4_log_200703182
As such, the 2nd part of the script barks the following errors:
c:\erase 03/18/2007
Invalid switch - "18"
I don't know how to change the output...
Thanks again! :)
Dominic
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'd recommend using Sirbounty's suggest with the inclusion of the /b dir switch:
dir *.* /b /s /a-a > C:\Deletionlist.txt
for /f %%a in (C:\DeletionList.txt) do erase "%%a"
dir *.* /b /s /a-a > C:\Deletionlist.txt
for /f %%a in (C:\DeletionList.txt) do erase "%%a"
ASKER
You are a genius! :)
That worked great! THANK YOU!
That worked great! THANK YOU!
That's true - Steve's (the REAL genius) verion might be a better, and less code, method...
Glad it worked for you though.
Glad it worked for you though.
Sirbounty's idea and he came up with the solution. Great work :)
dir *.* /s /a-a >> C:\Deletionlist.txt
Then perform the delete using
for /f %%a in (C:\DeletionList.txt) do erase %%a