I just need to move a file, with a changed name, from one folder to another.
Been experimenting with various versions of this with no luck.
set newPath to ((path to downloads folder as text) & “192.168.1.36:29:fs_” & (value of variable “iPhoneMovieNumber”) & “.mov”)
set targetPath to “Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes:A New iPhone Movie.mov”
tell application “Finder”
move newPath to targetPath
end tell
the Finder cannot move and rename a file at the same time.
Either first move it then rename it
set newPath to ((path to downloads folder as text) & "192.168.1.36:29:fs_" & iPhoneMovieNumber & ".mov")
set targetPath to "Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes:"
tell application "Finder"
set movedFile to move file newPath to folder targetPath
set name of movedFile to "A New iPhone Movie.mov"
end tell
or use the shell.
You should always add object specifiers (like file or folder) to Finder file actions. The raw string path is not sufficient
Thanks. Nuts, still can’t get it to work.
Maybe the catch is the insertion of the variable name into the path?
I’m executing this from within my home automation app Indigo.
Tried variations of this:
set newPath to ((path to downloads folder as text) & “192.168.1.36:29:fs_” & (value of variable “iPhoneMovieNumber”) & “.mov”)
set targetPath to “Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes”
tell application “Finder”
set movedFile to move file newPath to folder targetPath
set name of movedFile to “A New iPhone Movie.mov”
end tell
Edit: Ta Dah…got it too work, except it needs to write over the “A New iPhone Movie.mov” if it exists.
value of variable “iPhoneMovieNumber” is no valid AppleScript syntax unlike it’s part of a scripting addition or part of an application"s terminology. In the latter case it must be with an application tell block
set newPath to POSIX path of (path to downloads folder) & "192.168.1.36:29:fs_" & iPhoneMovieNumber & ".mov"
set targetPath to POSIX path of ("Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes:A New iPhone Movie.mov")
do shell script "/bin/mv -f " & quoted form of newPath & space & quoted form of targetPath
set newPath to POSIX path of (path to downloads folder) & “192.168.1.36:29:fs_” & (value of variable “iPhoneMovieNumber”) & “.mov”
set targetPath to POSIX path of (“Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes:A New iPhone Movie.mov”)
¨do shell script "/bin/mv -f " & quoted form of newPath & space & quoted form of targetPath
but get "Expected end of line but found unknown token.
set newPath to ((path to downloads folder as text) & “192.168.1.36:29:fs_” & (value of variable “iPhoneMovieNumber”) & “.mov”)
set targetPath to “Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes”
do shell script "/bin/mv -f " & quoted form of newPath & space & quoted form of targetPath
It’s a number stored in a variable in my automation app Indigo that determines the file number
to be moved. If the script is executed outside of Indigo that part won’t work.
Isn’t there something like “using replace” that could be added, or maybe delete the file before runnng
the move?
sigh, it’s hard to help just with a chunk of code.
You should move the shell part out of the Indigo tell block
tell application "Indigo"
--.
set iPhoneMovieNumber to value of variable "iPhoneMovieNumber"
end tell
set newPath to POSIX path of (path to downloads folder) & "192.168.1.36:29:fs_" & iPhoneMovieNumber & ".mov"
set targetPath to POSIX path of ("Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes:A New iPhone Movie.mov")
do shell script "/bin/mv -f " & quoted form of newPath & space & quoted form of targetPath
This one works, but leaves the original intact, it just copies it to the new location.
set newPath to ((path to downloads folder as text) & “192.168.1.36:29:fs_” & (value of variable “iPhoneMovieNumber”) & “.mov”)
set targetPath to “Indigo Backup:Users:TV:Music:iTunes:Automatically Add to iTunes”
tell application “Finder”
–delete file “Indigo Backup:Users:TV:Music:iTunes:Automatically Add to --iTunes:A New iPhone Movie.mov”
set movedFile to move file newPath to folder targetPath
set name of movedFile to “AA New iPhone Movie.mov”
end tell
I thought the move command would do just that, take the original and move it somewhere else.