0

How to copy files into a directory by AppleScript? Convert bash to AppleScript.

Please convert the following bash commandline code into AppleScript.

cd /Volumes/B
cp f1.txt f2.txt drc

Similarly, convert the following bash commandline code into AppleScript.

cp /Volumes/B/f1.txt /Volumes/B/f2.txt /Volumes/B/drc

f1.txt and f2.txt are regular files. drc is is a directory. In the first code, the files and directory for cp are expressed as relative paths. In the second code, they are absolute paths. I am not sure whether AppleScript has the concepts of "current directory" and "relative path".

1 Answer 1

1

Regarding the 2nd question, this should work

(detailing the step to make it clearer; you could make a loop)

tell application "Finder"
    set f1 to "B:f1.txt" as alias
    set f2 to "B:f2.txt" as alias
    set destpath to "B:drc:" as text

    duplicate f1 to folder (destpath)
    duplicate f2 to folder (destpath)
        
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .