I’m using 10.4 AppleScript Studio, but this code should work in Script Editor as well.
If I do the following, I get an error at the 5th line (
set fileList to files in folder localDirectory
)
on offloadData(machineURI)
tell application "Finder" of machine machineURI --"eppc://username:password@192.168.80.52"
set {localDirectory, remoteDirectory} to {"Macintosh HD:Users:localadmin:Movies:", "Video:Recent Videos:"}
set fileList to files in folder localDirectory
repeat with aFile in fileList
set theFile to aFile as alias
move file theFile to remoteDirectory
try
delete file theFile
on error
display dialog errormessage
end try
end repeat
empty trash
end tell
end offloadData
If I write it as the following script, I don’t have the problem.
on offloadData()
tell application "Finder" of machine "eppc://username:password@192.168.80.52"
set {localDirectory, remoteDirectory} to {"Macintosh HD:Users:localadmin:Movies:", "Video:Recent Videos:"}
set fileList to files in folder localDirectory
repeat with aFile in fileList
set theFile to aFile as alias
move file theFile to remoteDirectory
try
delete file theFile
on error
display dialog errormessage
end try
end repeat
empty trash
end tell
end offloadData
What is my bug, or is it a bug in Applescript?
If it is AppleScript, is it possible to work around it like this? I don’t get the error.
on offloadData(machineURI)
tell application "Quicktime Broadcaster" of machine machineURI --"eppc://username:password@192.168.80.52"
tell application "Finder"
set {localDirectory, remoteDirectory} to {"Macintosh HD:Users:localadmin:Movies:", "Video:Recent Videos:"}
set fileList to files in folder localDirectory
repeat with aFile in fileList
set theFile to aFile as alias
move file theFile to remoteDirectory
try
delete file theFile
on error
display dialog errormessage
end try
end repeat
empty trash
end tell
end tell
end offloadData