Hi all, I am trying to convert an applescript to ASOC for the purpose of adding a GUI in XCode. I am familiar with cocoa in xcode but I have never tried using applescript. When I set up my connections in interface builder and plugged in my code, vast amounts of it no longer work. Even simple things like
set newFolderName to date string of (current date)
tell application "Finder"
try
make new folder at ":Macintosh HD:Volumes:Server:Mackup on Server:Incremental Mackups:" with properties {name:newFolderName}
which used to work just fine no longer work at all. In this case, I get an error:
2010-03-18 15:14:09.098 Mackup[1691:a0f] *** -[MackupAppDelegate chooseDestFolder:]: Can’t make class «class asdr» of «script». (error -2710)
I cannot find anything on Google about this error, and its only one of many that occur though the script works perfectly as a normal applescript. What am I doing wrong?
I never worked with AppleScriptObjc, but I think the error is located in the script itself. I don’t think the alias-string should start with an “:”.
tell application "Finder" to try make new folder at folder "Macintosh HD:Volumes:Server:Mackup on Server:Incremental Mackups:" with properties {name:newFolderName}
end try
Oh, and another tip:
“Startup Disk:Volumes:A Hard Drive:sub:folder:file.txt”
is the same as
“A Hard Drive:sub:folder:file.txt”
Hi,
there are actually 2 syntax errors although plain AppleScript ignores them politely
¢ A HFS path should start with a disk name, not with :[startup volume]:Volumes:[disk name]
¢ the insertion location of the make command in the Finder should be a reference (alias or file specifier)
tell application "Finder"
make new folder at folder "Server:Mackup on Server:Incremental Mackups:" with properties {name:newFolderName}
end tell
However, on a shared volume I recommend to avoid the Finder for file system operations
do shell script "/bin/mkdir -p " & quoted form of ("/Volumes/Server/Mackup on Server/Incremental Mackups/" & newFolderName)
or, in AppleScriptObjC use NSFileManager.
Wow, this is revolutionary. All my errors so far have been resolved by changing the syntax. Thanks a ton guys!
-Fred
Using the proper syntax is always amazingly helpful