The idea with this script is that it should expand the contents of a folder. The first part gets the name/or names of the files, while the second part should expand the files. Well… the 2nd part doesn’t work. Is it because Stuffit doesn’t know the path to the folder or that i’m missing the applescript item delimiter or …? Can anyone give me a clue?
thanks
Fernando
set theHD to (path to startup disk as string)
set theFolder to theHD & “file name:”
tell application “Finder”
set theNames to get the name of every item of folder theFolder
end tell
tell application “StuffIt Expander”
activate
repeat with i from 1 to count of theNames
set theSource to (item i of theNames as string)
end repeat
Expand file theSource
quit
end tell
From what I see, right now it will only expand the last item in the folder, right? It looks like you need the expand command to be within the repeat command, like this:
tell application "StuffIt Expander"
activate
repeat with i from 1 to count of theNames
set theSource to (item i of theNames as string)
Expand file theSource
end repeat
quit
end tell
Malcom
-- large lump of boring cut-n-paste:
on asAliasList(finderRef)
(* provides a workaround for a bug in Finder's 'as alias list' coercion
finderRef : reference -- a *reference* to zero or more Finder disk/file/folder objects
Result : list of aliases
Example:
tell application "Finder"
my asAliasList(a reference to items of desktop) -- (note the use of 'a reference to' operator)
end tell
*)
try
if class of finderRef is list then -- do a quick-n-dirty check for an easily-made mistake
error "please pass a reference, not a list (of references)." number -1703
end if
tell application "Finder"
try
return finderRef as alias list
on error number -1700 -- ('as alias list' breaks when there's only one item)
return {finderRef as alias}
end try
end tell
on error eMsg number eNum
error "Can't get asAliasList: " & eMsg number eNum
end try
end asAliasList
-------
-- the bit that's actually interesting:
tell application "Finder"
set archivesFolder to folder "MyStuffitArchives" of home -- wherever
set filesRef to a reference to files of archivesFolder
end tell
set aliasList to asAliasList(filesRef)
tell application "StuffIt Expander" to Expand aliasList