Latest in Applescript

Image credit:

Friday Favorite: Use AppleScript to delete files from a folder

1 Shares
Share
Tweet
Share
Save

Sponsored Links

As part of my daily writing, I take a lot of screenshots and process a ton of images on my Mac. As a result, I have two ever-growing folders that are stuffed full of images that are not useful after I publish a post. Now that I have a MacBook Air and only 128 GB of storage space, I am much more concerned about keeping my files in check.

To help delete these files in bulk, I've been using this handy AppleScript:

try

tell application "Finder"

delete (every item of folder (path to desktop folder) whose name begins with "Screen Shot")

delete (every item of folder (path to downloads folder) whose name ends with ".jpg")

end tell

on error

display dialog ("Error. Couldn't Move the File") buttons {"OK"}

end try

You can modify it yourself to point to a different folder or to target different files. If you remove the qualifier "whose name begins with" and leave the line as "delete (every item of folder (path to desktop folder))", then you can delete all the contents of a folder in one fell swoop.

I don't need to run the script every day, so I've exported it as an application and run it once a week. It's not a fancy script, but it is a timesaver, which makes it invaluable for me. Hopefully, it will be of use to you, too.

In this article: AppleScript, OS X
All products recommended by Engadget are selected by our editorial team, independent of our parent company. Some of our stories include affiliate links. If you buy something through one of these links, we may earn an affiliate commission.
Share
1 Shares
Share
Tweet
Share
Save

Popular on Engadget

Engadget’s guide to Home Entertainment

Engadget’s guide to Home Entertainment

View
Tesla's crash test lab video shows real and virtual Model 3 wrecks

Tesla's crash test lab video shows real and virtual Model 3 wrecks

View
TiVo's 'free' streaming service starts rolling out

TiVo's 'free' streaming service starts rolling out

View
NASA demos spacesuits for its Moon and Mars missions

NASA demos spacesuits for its Moon and Mars missions

View
Sony’s 360 Reality Audio launches this fall with 1,000 tracks

Sony’s 360 Reality Audio launches this fall with 1,000 tracks

View

From around the web

Page 1Page 1ear iconeye iconFill 23text filevr