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

The best mobile devices for students

The best mobile devices for students

View
YouTube pulls hundreds of channels tied to Hong Kong influence campaign

YouTube pulls hundreds of channels tied to Hong Kong influence campaign

View
'Fortnite' finally nerfs the hated B.R.U.T.E. mechs

'Fortnite' finally nerfs the hated B.R.U.T.E. mechs

View
After a year of Epic Games exclusivity, ‘Hades’ heads to Steam Early Access

After a year of Epic Games exclusivity, ‘Hades’ heads to Steam Early Access

View
Porsche streamlines the Taycan EV’s infotainment system

Porsche streamlines the Taycan EV’s infotainment system

View

From around the web

Page 1Page 1ear iconeye iconFill 23text filevr