Problem with if exists finding multiple files...

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.

Hi. Welcome to MacScripter.

Both ‘choose file … with multiple selections allowed’ and the Finder’s ‘selection’ return a list of the chosen or selected item(s). To handle the items individually, you have to use a repeat to iterate through the list. I don’t understand the ‘Options’ business in your script, but to get duplications to work, you’d use something like this:

set newFiles to (choose file with prompt "Please Select Files" with multiple selections allowed)

-- Or:
(* tell application "Finder" 
 set newFiles to selection -- Could be files and/or folders
end tell *)

-- The Finder's happier creating references like 'file thisName of destinationFolder' if destination folder is an alias rather than a posix file. 
set destinationFolder to (POSIX file "/Users/username/path/tofolder") as alias

repeat with i from 1 to (count newFiles)
	set thisFile to item i of newFiles
	tell application "Finder"
		set thisName to thisFile's name
		if (exists item thisName of destinationFolder) then
			display dialog "Already exists in this location." buttons "OK" default button "OK" with title "Error" with icon caution
		else
			duplicate thisFile to destinationFolder
			display dialog "File successfully transfered" buttons {"Close"} default button 1
		end if
	end tell
end repeat