DonationCoder.com Software > Post New Requests Here
IDEA: Delete all files except two particular ones
skwire:
1. I'd prefer typing into the script the name of the folder to act upon in the deletion process, just to be absolutely sure. Would save user time as well, as opposed to the Windows navigation routine.
2. Possibly a way of giving a signal that task has been completed. "Done."-nkormanik (December 09, 2013, 08:34 PM)
--- End quote ---
Here you go:
--- Code: Autohotkey ---; Add filenames to save here, one per line.FileNamesToSave =(keep_this_one.pngsave_me_as_well.png) ; Folder to recurse.myFolder := "c:\5" Loop, % myFolder . "\*.png", 0, 1 ; Recurse through PNG files.{ ; Store some values. myFilename := A_LoopFileName myFileFullPath := A_LoopFileFullPath SaveFile := False ; Iterate through filenames to save and ; check against currently parsed filename. Loop, Parse, FileNamesToSave, `n, `r { If ( myFilename = A_LoopField ) { ; Filename to save matches. ; Set as true and break out. SaveFile := True Break } } If ( SaveFile = False ) { ; Change to FileDelete to delete directly. FileRecycle, % myFileFullPath }} MsgBox, Done. ExitApp
nkormanik:
Works great, Skwire.
One double-click takes care of a huge task. Amazing.
I'd say it's good to go.
Thanks!
rjbull:
I think your "snippet" deserves a name. Like, "Delete Except."-nkormanik (December 08, 2013, 11:27 PM)
--- End quote ---
I seem to remember an ancient DOS program called "DELBUT," meaning "delete everything but these." So would Tsahi Chitin's TDEL. There is no new thing under the sun, and continued development of PCs leads to continual reinvention of the wheel...
nkormanik:
Thanks, rjbull. I found and downloaded both.
After reading the help files, and knowing they are DOS, I'll take Skwire's solution.
Too, of huge importance, doesn't appear those programs are capable of "recursive" action. Skwire's handles huge trees of folders, easy peasy.
MilesAhead:
ahk does make plumbing the depths of folders really simple. A big time saver.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version