I’ve got a script that needs to move a number of files from a folder into a package application. I’m trying the following script:
tell application "Finder"
set ProgramFolder to container of file (path to me)
set TempFolder to (ProgramFolder as string) & "Update Items:"
end tell
try
tell application "Finder"
set FileList to every item of folder TempFolder
repeat with TheFile in FileList
move TheFile to folder "myapp.app" of ProgramFolder with replacing
end repeat
end tell
on error errmsg number errnum
display dialog "Num: " & errnum & " Msg: " & errmsg
end try
Running it gives the error “Finder got an error: Can’t get item 1 of {application file “myapp” of folder “Update Items” of startup disk, document file “update.ini” of folder “Update Items” of startup disk, document file “versionname” of folder “Update Items” of startup disk}.” The error number is -1728.
Any suggestions of what I’m doing wrong?
I’ve done some more testing, and rewriting part of the code gives a more informative (but still incorrect) error message.
tell application "Finder"
set ProgramFolder to container of file (path to me)
set TempFolder to (ProgramFolder as string) & "Update Items:"
end tell
try
tell application "Finder"
set FileList to every item of folder TempFolder
end tell
repeat with TheFile in FileList
set AnotherFile to TheFile as text
tell application "Finder"
move AnotherFile to folder "myapp.app" of ProgramFolder with replacing
end tell
end repeat
on error errmsg number errnum
display dialog "Num: " & errnum & " Msg: " & errmsg
end try
The error message is ‘Can’t get "Macintosh HD:Update Items:versionname’, error code -1728. Finder clearly has no problem getting the file, because if I remove the ‘folder “myapp.app” of’ part of the move command, things work fine. Is there a way I can temporarily turn a bundle back into an ordinary folder so I can move the files into it?