Move Files containing "Screen Shot" to another folder

Hey @agilefalcon,

It’s easy to do this job with AppleScript and a whose-clause using System Events – IF you’re not dealing with more than a few hundred files.

It only takes 6 lines of code…

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/03/24 12:33
# dMod: 2018/03/24 12:39 
# Appl: System Events
# Task: Move files whose name contains a string to a destination folder.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Move, @Files, @Whose, @Name, @Contains, @String, @Destination, @Folder
----------------------------------------------------------------

set sourceFolder to path to desktop folder
set destinationFolder to alias ((path to downloads folder as text) & "Test ⇢ Destination Folder:")

tell application "System Events"
   set fileList to (files of sourceFolder whose name contains "screen shot")
   move fileList to destinationFolder
end tell

----------------------------------------------------------------

Of course I’m not doing any error-checking here, as I would in a production script.

Now then – let’s get a bit more sophisticated and use a regular expression to find our files:

AppleScript ⇢ Working with Files and Folders

-Chris