Highlighted

Copy the files from one folder to another folder using applescript got an error

Community Beginner ,
Nov 17, 2020

Copy link to clipboard

Copied

Hi,
 

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

TOPICS
Scripting

Views

17

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Copy the files from one folder to another folder using applescript got an error

Community Beginner ,
Nov 17, 2020

Copy link to clipboard

Copied

Hi,
 

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

TOPICS
Scripting

Views

18

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 17, 2020 1

Have something to add?

Join the conversation
Resources