Sorting Script

I’m a prepress operator, and so I am constantly taking in client files.

I maintain a stringent folder structure. Inside the job folder are the following folders:

fonts
customer_originals
scans
vectors
working_files

When I receive a job I copy the client disk to the customer_originals folder. I maintain that copy intact in case I need to refer back to the original files. I copy the relevant files into the appropriate folders.

I’m trying to build a script that will copy these files into the appropriate folders based on creator code (file type would work except for the EPSF file type).

The creator codes I generally see are:
XPRC from QuarkXpress (working_files)
InDn from InDesign (working_files)
Fonts - DMOV, ASPF, hDmp (fonts)
ART5 from Illustrator (vectors)
FH11 from Freehand (vectors)
8BIM from Photoshop (scans)
CARO from Acrobat (vectors)

I’d like to set this up so I can drop the job folder on the script and have it run. I’ve also put in another folder called “errors” to catch everything that doesn’t fit into any of the previous categories.

So far I have:

try
	tell application "Finder" to set the source_folder to the folder returned of the result
end try

tell application "Finder"
	(document files of source_folder) / customer_originals
	if creator type is "XPRC" or "InDn" then
		duplicate to source_folder / working_files with replace
	else
		return
	end if
	if creator type is "DMOV" or "ASPF" or "hDmp" then
		duplicate to source_folder / _fonts with replace
	else
		return
	end if
	if creator type is "ART5" or "FH11" then
		duplicate to source_folder / vectors with replace
	else
		return
	end if
	if creator type is "8BIM" then
		duplicate to source_folder / scans with replace
	else
		duplicate to source_folder / errors
	end if
end tell

I also can’t figure how I’m gonna’ make it run through all the sub-folders.

Thanks,
rich

Are you really running OS 9? If not I can help you.

No. I’m on OSX.4.7. I meant for this post to go over to the OSX forum. Sorry.

Rich

[Thread moved over, Adam Bell]

I haven’t tested this, but the form you want is like this:


-- all the folders involved have to be defined and are assumed to exist. You don't say you want to create them.
set the source_folder to (choose folder) as text
set working_files to (choose folder) as text
set _fonts to (choose folder) as text
set _vectors to (choose folder) as text
set scans to (choose folder) as text
set errors to (choose folder) as text
-- in place of all those choose folders, you can specify the exact addresses.
tell application "Finder"
	set allFiles to files of alias (source_folder & customer_originals) as alias list
	repeat with aFile in allFiles
		if creator type of aFile is "XPRC" or "InDn" then
			duplicate aFile to alias (source_folder & working_files) with replacing
		else if creator type is "DMOV" or "ASPF" or "hDmp" then
			duplicate aFile to alias (source_folder & _fonts) with replacing
		else if creator type is "ART5" or "FH11" then
			duplicate aFile to alias (source_folder & _vectors) with replacing
		else if creator type is "8BIM" then
			duplicate aFile to alias (source_folder & scans) with replacing
		else
			duplicate aFile to alias (source_folder & errors) -- replacing??
		end if
	end repeat
end tell

Thanks, Adam.

In a quick test I get the error, “…the variable ‘customer_originals’ is not defined…”

I’ll bang on it a while.

Will this structure run through whatever sub-folders might be present in the customer_originals folder?

rich

add a line near the top to define customer_originals by choosing its folder (as for the others) or use a specific path.

As structured, this will not go through subfolders but if you don’t care about the sub-folders themselves, then inside your Finder block, replace the allFiles definition with this:


set allFiles to files of entire contents of alias (source_folder & customer_originals) as alias list

Quite a bit more work is required if you want to recreate the folder structure found in the customer_originals folder in your sorted folders.

As an afterthought; you haven’t made clear what your work process is, but if you start with an enclosing folder containing the customer_originals folder, your script can first create all the others, and then move duplicates to them. See the Finder dictionary for “make”. You’d use it like so: set _fonts to make new folder at enclosing_folder_path with properties {name:“_fonts”}

I’m not following you here. The script needs to copy all the files from all the subfolders. Client disks are like a boxes of chocolates, you never know what you’ll get. :stuck_out_tongue:

No. I don’t want to recreate the folder structure. I want to copy all the files into my folder structure.

I’ve got a folder residing on my desktop called “new job folder”. It contains all the subfolders described. I just copy it to the server, rename it with the job number and client name, copy the disk(s) to the customer_originals folder, and then begin the sorting process. I was trying to start simple.sort of.

Thanks,
rich

I guess I wasn’t clear with this:

What I meant was this: replace the allFiles definition in my earlier script above with this new one (just above - just copy from one script, paste in the other, in the right place of course). The new statement will “dig down” (that’s what ‘entire contents’ is for) through all the objects in the enclosing folder that are of type file and ignore the internal folders containing them (not the contents, just the folder as an item itself). It lists every file in the outer folder all the way down through the hierarchy of the outer folder’s contents whether some of those are in folders or not.