I’m having some trouble with something very, very easy. I’m just too new to this and am not sure how to find what I’m looking for.
I’m trying send files from a selection to a folder of my choosing. I’m running into a few issues here with the if exists. My prompt will allow me to select one or multiple files and duplicate them to a selected folder but the if exists only works with one file. If i’ve selected multiple files it will duplicate all of them into the folder and just add a number to the end of the file name.
The if exists does not work with the selection at all. One file or all selected files. I’m really not sure what’s going on there.
This is the script I’ve been editing minus a few specifics:
(*choose file with prompt will work with one file. multiple selections will copy and paste files into folder even when duplicates already exist*)
set newFile to choose file with prompt "Please Select Files" with multiple selections allowed
(*when trying to use the the tell application "Finder" command instead of using the prompt I can't get the if exists to work at all. Not even with one file selected.*)
--tell application "Finder"
--set newFile to selection
set Options to choose from list {"Folder 1", "Folder 2", "Folder 3", "Folder 4"} with prompt "Send selected files to Shared Drive:" with multiple selections allowed
if Options contains "Folder 1" then
tell application "Finder"
if exists newFile then
display dialog "Already exists in this location." buttons "OK" default button "OK" with title "Error" with icon caution
else
duplicate newFile to "/Users/username/path/tofolder" as POSIX file
display dialog "File successfully transfered" buttons {"Close"} default button 1
end if
end tell
else
display dialog "It didn't work. Call for help." buttons {"Close"} default button 1
end if
--end tell
I’m sure I’m doing something incredibly dumb but I’m really not seeing it.