I’ve been trying to learn AS for a few weeks, and have managed to get to a reasonable point in my first project, but now I’m faced with the next challenge and can’t seem to find posts which cover this - I’m probably looking for the wrong search term.
I managed to successfully “add” a file to my toast project using the following scripts:
set file_to_add to ":Users:steveg:Desktop:CFCARD:EVNZ0001.MPG" as alias
and then later in the script:
add to toast_project items (every file of thePath)
. . . but I’m stuck, if there’s more than one file I need to “Add” to the project.
Can anyone either - advise me what search term I need to look for on the forums, or point me in the right direction for adding multiple files to the project.
Any help would stop me pulling the rest of my (limited) hair out, this morning!
the add command expects obviously one or more aliases. every file of thePath looks like a line within a Finder tell block.
Finder file specifiers must be coerced to alias.
And be careful not to mix up application tell blocks
I’m using Toast 11 and at this point I have this script:
set files_to_add to "HD2:sjungarna_inspelningar:199 - Mohedaskolan:bounce:1.wav" as alias
tell application "Toast Titanium"
add to current disc items files_to_add
end tell
I want to be able to add multiple files but without the choose file option, but point directly to file files.
This should get a list with aliases, wich I believe will work, if not, then you’ll have to iterate over the list, adding one item at a time.
tell application "System Events"
set ml to every file of folder "HD2:sjungarna_inspelningar:199 - Mohedaskolan:bounce:" as alias as list
end tell
tell application "Toast Titanium"
add to current disc items ml
end tell
Repeating over the track list would look something like below, this code is just for prosperity, as I don’t have Toast, so it is untested!
tell application "Toast Titanium"
repeat with aTrack in ml
add to current disc items aTrack
# I don't know toast
end
end tell
I used this some years ago, save it as application (bundle).
You can drop files onto the icon or run it normally
on run
set theseFiles to choose file with prompt "Choose files to write on disk" with multiple selections allowed
toast(theseFiles)
end run
on open theseFiles
toast(theseFiles)
end open
on toast(filesToToast)
display dialog "Enter Disk Name" default answer "" buttons {"Cancel", "OK"} default button "OK"
set diskName to text returned of result
tell application "Toast Titanium"
activate
set newDisk to make new Data disc with properties {name:diskName, file system type:Mac OS Extended}
add to newDisk items filesToToast
write newDisk
end tell
end toast
your script returns this error for every file in the folder.
"Can’t make {file "HD2:sjungarna_inspelningar:199 - Mohedaskolan:bounce:1.wav" of application "System Events"
SInce I have near to zero troubleshooting skills here I pretty much don’t know what to do…
That is surely a good thing to know! Thanks Stefan!
I don’t like it though, I think it would be much more logical if they all represented the same thing, and System Events let me down this time! That an alias list is different from as alias as list, is also a bit startling.
( I just recently learned that from Leopard onwards, an alias doesn’t need to exist In AppleScript, that is, you can make an alias to a non existent file. First, and for along time, I thought it was BBEdit that behaved peculiarly. )
I am not sure what the purpose of a non-existant alias. But I read that it was possible.
It turned out that I missed a detail here, and that is that it was resolved compile time in AppleScript 1.9 but is resolved at run-time in AppleScript 2.x. Still, I have experienced that a non-existant alias haven’t generated run time errors at least inside BBEdit tell blocks. And it happened once outside a BBEdit tell block too, for some reason, and then I looked it up last time, somewhat hastily. After last time, I started using exists, within System Events and Finder blocks!
I looked it up, both in ASLG and in the Dictionary.