Created
June 14, 2018 08:52
-
-
Save watershed/7e7ad2dfeeb5022c4902bd2c3d181ec3 to your computer and use it in GitHub Desktop.
Select files from list AppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set myValues to {"filename.ext", "filename.ext"} | |
tell application "Finder" to set fileList to files of target of front Finder window as alias list | |
set matchedFiles to {} | |
repeat with aFile in my fileList | |
repeat with aValue in myValues | |
tell application "System Events" to if aFile's name contains (contents of aValue) then set end of matchedFiles to (aFile as text) | |
end repeat | |
end repeat | |
if matchedFiles ≠ {} then | |
tell application "Finder" | |
select matchedFiles -- you don't need to select files to duplicate them | |
duplicate matchedFiles to (choose folder) | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very inefficient and pounds the CPU. Much better off using something like the following in the command line:
cp ~/source/folder/{filename.ext,filename.ext} ~/destination/folder/