Hi all,
I am new to Applescript and would appreciate a bit of troubleshooting from someone! I would like to have a script that copies any files with the word "Data" in their file name on a memory stick (KINGSTON) to a folder of my choice, as long as they are not already in that folder. The script below works fine if I use the "choose folder" thing (sorry, I have little knowledge of technical terms!) as I do for setting the target folder, but not if I do the "files of folder" thing. I guess it is something to do with syntax then? I get the error "Finder got an error: Cant get folder "/Volumes/KINGSTON"."
Thanks in advance,
K
I am new to Applescript and would appreciate a bit of troubleshooting from someone! I would like to have a script that copies any files with the word "Data" in their file name on a memory stick (KINGSTON) to a folder of my choice, as long as they are not already in that folder. The script below works fine if I use the "choose folder" thing (sorry, I have little knowledge of technical terms!) as I do for setting the target folder, but not if I do the "files of folder" thing. I guess it is something to do with syntax then? I get the error "Finder got an error: Cant get folder "/Volumes/KINGSTON"."
Thanks in advance,
K
Code:
on run {input, parameters}
tell application "Finder"
set the_files to (files of folder "/Volumes/KINGSTON")
set target_folder to (choose folder with prompt "Choose the target folder:")
repeat with this_file in the_files
set this_file_name to name of this_file --name is a property of a window
if this_file_name contains "Data" then
if (not (exists file this_file_name of target_folder)) then
duplicate this_file to target_folder
end if
end if
end repeat
end tell
return input
end run