I am trying to dupe the file from one folder to another folder with below codes.
on run {input, parameters}
set collectPaths to {}
repeat with i from 1 to (input count)
set collectPaths to item i of input as string
end repeat
tell application "System Events"
set fileList to (every folder of folder collectPaths whose name is "Old")
if (count of fileList) is equal to 0 then
tell application "Finder"
set x to make new folder at input with properties {name:"Old"}
end tell
else
set x to fileList
end if
end tell
tell application "System Events"
set fileList to (every file of folder collectPaths whose name extension is "ai")
repeat with i from 1 to count of fileList
set theItem to item i of fileList
tell application "Finder"
duplicate the file theItem to the folder x
end tell
end repeat
end tell
end run
But I got an error as "The action “Run AppleScript” encountered an error: “Finder got an error: Can’t make alias of folder "Old" of folder "untitled folder 2" of folder "Desktop" of folder "asuvathdhamank" of folder "Users" of startup disk into type string.”
Please help me out from this and dupe the file on that Old folder