To repeat or transfer file to a unique folder utilizing Terminal, the plain means is to make use of the cp
and mv
instructions.
However for customers who typically put necessary info within the “Feedback” part of the “Get Information” window of their recordsdata and folders, cp
and mv
have a disadvantage that feedback are typically misplaced.
The one dependable means I’ve discovered to this point to repeat/transfer recordsdata utilizing Terminal and protect feedback is to make use of AppleScript.
I’ve a number of snippets for that, however presently they work simply to display the thought, and that’s to say, they don’t seem to be a script that you should utilize with arbitrary targets and locations like cpx
. Right here they’re, simply in case, and although I might be very appreciated for assist to transform them right into a script that may work like cpx
, this isn’t what my query is about.
Suppose you will have
~/ |- dir1/ |- dir2/ | |- dir3/ | |- file | |- dir4/ |- dir5/
Then:
to repeat the file to dir3, use:
osascript << SCRIPT set currentFolder to "$(pwd)" as POSIX file as textual content inform utility "Finder" duplicate file (currentFolder & "file") to folder (currentFolder & "dir3:") finish inform SCRIPT
to repeat it to dir4, use both
osascript << SCRIPT set currentFolder to "$(pwd)" as POSIX file as textual content set parentFolder to "$(dirname $PWD)" as POSIX file as textual content inform utility "Finder" duplicate file (currentFolder & "file") to folder (parentFolder & "dir4:") finish inform SCRIPT
or
osascript << SCRIPT set currentFolder to "$(pwd)" as POSIX file as textual content inform utility "Finder" set parentFolder to (container of folder currentFolder) as textual content duplicate file (currentFolder & "file") to folder (parentFolder & "dir4:") finish inform SCRIPT
And right here is my query: Possibly I overcomplicate issues and as a substitute of utilizing AppleScript, I can use one thing much like open -a
?
# this works. that is used to open a file utilizing a selected app
open -a
# this does not work and only a demonstration of my concept
copy -a finder