Finder error when telling DropStuff to Zip

I get a Finder error:

“Finder got an error: item 1 of folder "T2-ES2-3.eps" of folder "Rsi Data" of folder "36816 Thomas" of folder "bigones" of folder "Rampage_RSI_Archive2Bup" of disk "RamVol" doesn’t understand the zip message.”

Here’s the code. Notice that the zip keyword is inside a tell app DropStuff block.
Why would Finder try to process something in a DropStuff tell block? EDIT: I think I need to change the line [zip item i of FolderContents2Compress] to [zip (item i of FolderContents2Compress) to FolderContents2Compress]?
or should I not use DropStuff at all?


(*Compress folders into separate zips*)


tell application "Finder"
	set Folder2process to choose folder with prompt "Choose Folder to Compress"
	set FolderContents2Compress to item 1 of Folder2process
	set FolderCount to (count items of FolderContents2Compress) as integer
	set i to 0
end tell

tell application "DropStuff"
	activate
	repeat with i from 1 to FolderCount
		zip item i of FolderContents2Compress
		set i to i + 1
		
		
		
	end repeat
	
end tell



Here is DropStuff’s Dictionary for Zip:

zip‚v : compress a set of file system objects as a Zip archive

[b]zip[/b] list of alias : item(s) to zip
	[[b]to[/b] alias] : a location to place the new archive. The default is to create the new archive in the same location as the source items.
	[[b]compression level [/b]better/faster/custom/none] : compression level to be used for the archive (default: better)
	[[b]password[/b] string] : optional password to use to encrypt the archive
	[[b]preserve macintosh content[/b] boolean] : Macintosh files that contain resource forks will saved using the M format. Default is true.
	[[b]ignore desktop files[/b] boolean] : ignore Finder files such as .DSStore (default: true)
	[[b]encode [/b]Binhex/UUCode/none] : Encode the archive for transmission via email or ftp. Default is none.
	[[b]adjust extension[/b] boolean] : remove the ".zip" from the extension after encoding (default: true)
	→ list of alias : the created archive

Edit2:

Now the error is from DropStuff which reads:
“DropStuff got an error: Can’t make item 1 of alias "RamVol:Rampage_RSI_Archive2Bup:bigones:36816 Thomas:Rsi Data:T2-ES2-3.eps:" into type file.”


tell application "Finder"
	set Folder2process to choose folder with prompt "Choose Folder to Compress"
	set FolderContents2Compress to item 1 of Folder2process
	set FolderCount to (count items of FolderContents2Compress) as integer
	set FolderContents2Compress to FolderContents2Compress as alias -- EDITED: added this line
	set i to 0
end tell

tell application "DropStuff"
	activate
	repeat with i from 1 to FolderCount
		zip (item i of FolderContents2Compress) to alias FolderContents2Compress -- EDITED: added "to alias"
		set i to i + 1
		
		
		
	end repeat
	
end tell



I don’t have DropStuff (I just use the shell version of zip with a script by StefanK), but it may be that you have to get the contents of the folder as an alias list to present to it rather than just an alias to the folder.

Stefan’s script:

set theFolder to choose folder
zipFiles(theFolder)

on zipFiles(theFolder)
	tell application "Finder" to set fileList to files of theFolder
	repeat with f in fileList
		set {name:Nm, name extension:Ex} to info for (f as alias)
		if Ex is missing value then set Ex to ""
		if Ex is not "" then set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
		set sourceFile to quoted form of POSIX path of (f as alias)
		set zipFile to quoted form of (POSIX path of (theFolder as Unicode text) & Nm & ".zip")
		do shell script "/usr/bin/zip -jqmo9 " & zipFile & space & sourceFile
	end repeat
end zipFiles

(*
Notes for used zip parameters: 
-j   junk (don't record) directory names
-q   quiet operation 
-m   move into zipfile (delete files)
-o   make zipfile as old as latest entry
-9   compress better 
*)

Hi, tlotzer.

The Finder returns files and folders in the form of Finder references, which DropStuff doesn’t understand.

In your first script, ‘FolderContents2Compress’ is such a Finder reference, so DropStuff can’t do anything with it.

In the second script, you’ve coerced the reference to alias, which is good if you want DropStuff to zip that particular item. But in both scripts, you’re telling DropStuff to identify and zip individual sub-items of ‘FolderContents2Compress’, which is presumably a folder. DropStuff doesn’t know how to get the items in a folder, so you need to get the Finder to return a list of them (as aliases).

Your process doesn’t make much sense to me, since it asks for a “Folder to Compress” but (apparently) attempts to compress individual items in a subfolder of that folder. But assuming that’s what you actually want, the code would look something like this:

tell application "System Events" to set DropStuffAlreadyOpen to (application process "DropStuff" exists)

set Folder2process to (choose folder with prompt "Choose Folder to Compress")
tell application "Finder"
	set FolderContents2Compress to item 1 of Folder2process
	try
		set FolderContents2Compress to items of FolderContents2Compress as alias list
	on error
		set FolderContents2Compress to {item 1 of FolderContents2Compress as alias}
	end try
end tell

tell application "DropStuff"
	activate
	repeat with i from 1 to (count FolderContents2Compress)
		zip (item i of FolderContents2Compress)
	end repeat
	if not (DropStuffAlreadyOpen) then quit
end tell

Thanks to you both.

I’ve written a few Applescripts for work, here in the Prepress dept of a printing company.

I have successfully been able to pull out log files from their child folders, rename them with the client job number info and saved in a separate folder.

Working out the alias’s were a real challenge.

I don’t really understand when to use them and when not to.

I will study your examples and the wealth of others on this site.

tlotzer;

Aliases are almost always a good idea except within a concatination like this:

set myFilePath to alias ((path to documents folder as text) & "myFile.txt")

Even when collecting files from a folder, I use this:

set F to choose folder
tell application "Finder" to try
	set myFiles to files of F as alias list
on error -- only one file in folder (a bug)
	set myFiles to files of F as alias as list
end try
myFiles

This returns the first item inside the chosen folder. Is that what you really want?

No, but from earlier study, the Finder needs to grab the first item in order to set the variable. I can’t remember when that is true, though.

The folder structure I’m trying to compress looks like this:

XXXXX_Jobname
Folder1
Folder2
Folder3
Folder4
Folder5

I need to Zip Folder1, Folder2, etc. separately and leave the Parent Folder alone. The reason is that I was just zipping large 3.6Gb or job folders, but when restoring, I just need the child folders: Folder1, Folder2, etc. I don’t want to unzip the whole thing, just Folder1, etc.

I don’t have DropStuff, but you can try something like this:

tell application "System Events" to set DropStuffAlreadyOpen to (application process "DropStuff" exists)

choose folder with prompt "Compress subfolders of this folder:"
set sourceFolder to result

tell application "Finder"
	try
		set folderList to folders of sourceFolder as alias list
	on error
		-- `as alias list` currently throws an error when there is only one item
		set folderList to folders of sourceFolder as alias as list
	end try
end tell

tell application "DropStuff"
	activate

	repeat with thisItem in folderList
		zip thisItem
	end repeat

	if not (DropStuffAlreadyOpen) then quit
end tell

i is automatically incremented; You don’t need to do it yourself.

See also: Repeat Statements

I tried the Do shell script below and it only zipped one file, not the whole folder contents. Here is the folder, before-n-after. Every item in the “T2-LT copy.eps” folder are folders except the T2-LT.ps file which is the only thing that it zips.

Before:

T2-LT copy.eps
Debug
Font Cache
Fpo
Helper
Monitor Proof
Prescan
Rdm
Rip
Screened
Stats
T2-LT.ps
Trap

After:

T2-LT copy.eps
Debug
Font Cache
Fpo
Helper
Monitor Proof
Prescan
Rdm
Rip
Screened
Stats
T2-LT.zip
Trap

Here’s the code:


set Folder2process to choose folder with prompt "Choose Folder to Compress"
zipFiles(Folder2process)

on zipFiles(Folder2process)
	tell application "Finder" to set fileList to files of Folder2process
	repeat with f in fileList
		set {name:Nm, name extension:Ex} to info for (f as alias)
		if Ex is missing value then set Ex to ""
		if Ex is not "" then set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
		set sourceFile to quoted form of POSIX path of (f as alias)
		set zipFile to quoted form of (POSIX path of (Folder2process as Unicode text) & Nm & ".zip")
		do shell script "/usr/bin/zip -jmo9 " & zipFile & space & sourceFile
	end repeat
end zipFiles


(*
Notes for used zip parameters: 
-j   junk (don't record) directory names
-q   quiet operation 
-m   move into zipfile (delete files)
-o   make zipfile as old as latest entry
-9   compress better 
*)

Here’s the Result Window:

tell current application
choose folder with prompt “Choose Folder to Compress”
alias “RamVol:Rampage_RSI_Archive2Bup:bigones:36816 Thomas:Rsi Data:T2-LT copy.eps:”
end tell
tell application “Finder”
get every file of alias “RamVol:Rampage_RSI_Archive2Bup:bigones:36816 Thomas:Rsi Data:T2-LT copy.eps:”
{document file “T2-LT.ps” of folder “T2-LT copy.eps” of folder “Rsi Data” of folder “36816 Thomas” of folder “bigones” of folder “Rampage_RSI_Archive2Bup” of disk “RamVol”}
get document file “T2-LT.ps” of folder “T2-LT copy.eps” of folder “Rsi Data” of folder “36816 Thomas” of folder “bigones” of folder “Rampage_RSI_Archive2Bup” of disk “RamVol”
alias “RamVol:Rampage_RSI_Archive2Bup:bigones:36816 Thomas:Rsi Data:T2-LT copy.eps:T2-LT.ps”
end tell
tell current application
info for alias “RamVol:Rampage_RSI_Archive2Bup:bigones:36816 Thomas:Rsi Data:T2-LT copy.eps:T2-LT.ps” given «class Krtn»:{name:“nm”, name extension:“ex”}
{name:“T2-LT.ps”, creation date:date “Monday, January 22, 2007 9:06:50 AM”, modification date:date “Monday, January 22, 2007 9:06:50 AM”, icon position:{0, 0}, size:6.0567528E+7, folder:false, alias:false, package folder:false, visible:true, extension hidden:false, name extension:“ps”, displayed name:“T2-LT.ps”, default application:alias “Macintosh HD:Applications:Preview.app:”, kind:“PostScript document”, file type:"

Previous post got truncated, this is all I could put in

Here’s the rest of the Result Window:

tell current application
do shell script “/usr/bin/zip -jmo9 ‘/Volumes/RamVol-1/Rampage_RSI_Archive2Bup/bigones/36816 Thomas/Rsi Data/T2-LT copy.eps/T2-LT.zip’ ‘/Volumes/RamVol-1/Rampage_RSI_Archive2Bup/bigones/36816 Thomas/Rsi Data/T2-LT copy.eps/T2-LT.ps’”
" adding: T2-LT.ps (deflated 22%)"
end tell

You asked for files and that’s what it gave you. Try folders or items instead.