Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Silly John Fatty

macrumors 68000
Original poster
Nov 6, 2012
1,806
514
Is there a way to put files that you have started to download but which, for some reason, you have cancelled to download, or which happen to be incomplete, automatically to the trash or automatically deleting them right away?

I don’t want to go to the Downloads folder and have to delete them manually each time.
 

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
Is there a way to put files that you have started to download but which, for some reason, you have cancelled to download, or which happen to be incomplete, automatically to the trash or automatically deleting them right away?

I wrote an Applescript to accomplish this ages ago. It still works:
Code:
-- Looks for files in the download folder containing ".part" etc
-- and moves them to the trash
-- BP 2010


set exttolookfor to ".part"
set php to ".php"
set webpage to ".htm"
set testlook to ".xyz" -- <-- just used for testing
-- set prependedstr to " " <-- I prefer to just make em easy to find rather than moving to trah

set src to ((path to home folder) as text) & "Downloads"
--display dialog src

set filenames to {}

tell application "Finder"
	copy ((name of every file of the folder src) as list) to filenames
	set numfiles to the number of files in the folder src
	--display dialog numfiles
	set n to 1
	repeat while n is less than or equal to numfiles
		
		
		set oldnam to item n of filenames as string
		
		if oldnam contains exttolookfor or oldnam contains php or oldnam contains webpage or oldnam contains testlook or oldnam starts with "showthread" or oldnam starts with "browse" then
			
			--set newname to prependedstr & oldnam
			--set the name of file oldnam of the folder src to newname
			move file (src & ":" & oldnam) to trash
			
		end if
		
		set n to n + 1
	end repeat
end tell

return
 

Dalton63841

macrumors 65816
Nov 27, 2010
1,449
8
SEMO, USA
That script is pretty cool, but does have 2 basic flaws.

1. Safari uses a .download suffix now.
2. It can't be scheduled. If you schedule it to run and it executes in the middle of a download, it will move a file that is in the middle of downloading to the trash.
 

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
Oh dear, I failed to supply a complete solution to everyone's problems. ;)
I use Firefox, don't care about safari.
If you want total automation, you'll need to work out conflict resolution yourself, or find someone else to do it for you.
 

Dalton63841

macrumors 65816
Nov 27, 2010
1,449
8
SEMO, USA
Oh dear, I failed to supply a complete solution to everyone's problems. ;)
I use Firefox, don't care about safari.
If you want total automation, you'll need to work out conflict resolution yourself, or find someone else to do it for you.

LMAO I was mostly just pointing out it may not help the OP.

Actually though with just a little tweaking it would cover both issues I mentioned, although off the top of my head I'm not sure how to make it ignore currently downloading files.
 

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
Yeah, it's a starting point, that's all. The version I actually use includes a lot more file types, and fancier substring searches. As far as ignoring downloads in progress, you could probably prevent most problems by not moving anything to trash that's been modified in the last 12 hours. With a reasonable internet connection that should protect even most movie or OS downloads from premature trashing.
 

jsdraven

macrumors newbie
Aug 14, 2013
5
0
Sonora, CA
LMAO I was mostly just pointing out it may not help the OP.

Actually though with just a little tweaking it would cover both issues I mentioned, although off the top of my head I'm not sure how to make it ignore currently downloading files.

I would have get your script to grab today's date then during your loop before you compare the file name compare the creation date as it should be same day. just ignore the matches. If you need you may be able to do some math on the stamp and fine tune the time if that matters to you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.