Need help: QXPress script to replace red color with black

Hi MP

When i test this with a quark doc and a quark template it works fine if you want to change a standard quark doc
to a template then you do need to "save as template true"etc. in your script but if it is already that kind it will stay that kind when it saves.
try this:

set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder" to set theFiles to (files of entire contents of processFolder whose file type is "XPRJ" or file type is "XPRT") as alias list
repeat with aFile in theFiles
	tell application "QuarkXPress"
		open aFile use doc prefs yes
		set x to name of document 1
		tell document 1
			set the color of every line box to "Black"
			set suppress printing of every generic box to false
			set thepath to (path to desktop folder) & x as string
			save in thepath
			close saving no
		end tell
	end tell
end repeat

Yes, you should be able to use the original path to overwrite the original file. I have not done this with a template but it should just be a matter of setting the properties in the save line correctly. I don’t have Quark here to test so can’t be of much more help at the moment…

I really appreciate all your support! Thank you so much! Should not be too far to go from here. But still I need to have them saved using original name.
Don’t fully understand the script yet but when reviewing it (and the event log), I assume that this line “set x to name of document 1” should already have given the original name to the actual document. Unfortunately the output files are still just named ‘Project 1’, ‘Project 2’…
Maybe the log helps. I took more or less pigde1’s script, just changed the output path (2 files were processed for testing):


tell current application
	choose folder with prompt "Choose a folder that contains files to process"
		alias "iMac_Admin2:Users:Admin2:Desktop:testfolder:"
end tell
tell application "Finder"
	get every file of entire contents of alias "iMac_Admin2:Users:Admin2:Desktop:testfolder:" whose file type = "XPRJ" or file type = "XPRT"
		{alias "iMac_Admin2:Users:Admin2:Desktop:testfolder:701. Digipack 10S", alias "iMac_Admin2:Users:Admin2:Desktop:testfolder:704. Insert 374,5 x 143,0 mm"}
end tell
tell application "QuarkXPress Passport"
	open alias "iMac_Admin2:Users:Admin2:Desktop:testfolder:701. Digipack 10S" use doc prefs yes
	get name of document 1
		"Project1"
	set color of every line box of document 1 to "Black"
	set suppress printing of every generic box of document 1 to false
	save document 1 in "iMac_Admin2:Users:Admin2:Desktop:Out:Project1"
	close document 1 saving no
	open alias "iMac_Admin2:Users:Admin2:Desktop:testfolder:704. Insert 374,5 x 143,0 mm" use doc prefs yes
	get name of document 1
		"Project2"
	set color of every line box of document 1 to "Black"
	set suppress printing of every generic box of document 1 to false
	save document 1 in "iMac_Admin2:Users:Admin2:Desktop:Out:Project2"
	close document 1 saving no
end tell

To overwrite the template file that you are opening try this:

set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder" to set theFiles to (files of entire contents of processFolder whose file type is "XPRJ" or file type is "XPRT") as alias list
repeat with aFile in theFiles
	tell application "QuarkXPress"
		open aFile use doc prefs yes
		tell document 1
			set the color of every line box to "Black"
			set suppress printing of every generic box to false
			save in (aFile as string)
			close saving no
		end tell
	end tell
end repeat

If it is a template then it will overwrite the file as a template, if it is a document it will save it as a document. I tried to force it to template using “with template” but get an error 69. It seems to work using “without template” to force the documents to a save as a regular Quark document.

Hi MP

The names of the files that the script creates are always gonna be the same unless you save them by a different name
its just like you would do if you were saving them manually in quark you have the option to rename:

set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder" to set theFiles to (files of entire contents of processFolder whose file type is "XPRJ" or file type is "XPRT") as alias list
repeat with aFile in theFiles
	tell application "QuarkXPress Passport"
		open aFile use doc prefs yes
		set x to name of document 1
		tell document 1
			set the color of every line box to "Black"
			set suppress printing of every generic box to false
			set thepath to (path to desktop folder) & x & space & "mpeshen" as string
			save in thepath
			close saving no
		end tell
	end tell
end repeat

this script adds your name to the end of the file when saved you can get rid of the x if you want but then you will have to
write in some code to differentiate between each file otherwise you’ll get the “this name already exists in that location” error.
another repeat loop that adds sequential numbering will sort that.

Pidge,

I think that the problem that he is having is that when you open a template file the name of the document is not the file name of the template. Quark names it Project 1, 2, 3, etc. It is basically like using the new project menue but using a previousely set up document to base the new document off of. So you need to grab the name of the file from the Finder to save or just use the original file path and overwrite the file. This would not be a problem if he were dealing with document files as they would retain the file name when opened.

Jerome

oops sorry jerome! MP

I know exactly what you mean i use templates in illustrator all the time it works just the same.
try this:

set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder" to set theFiles to (files of entire contents of processFolder whose file type is "XPRJ" or file type is "XPRT") as alias list
repeat with aFile in theFiles
	tell application "Finder" to set n to name of aFile
	tell application "QuarkXPress Passport"
		open aFile use doc prefs no
		set x to name of document 1
		tell document 1
			set the color of every line box to "Black"
			set suppress printing of every generic box to false
			set thepath to (path to desktop folder) & n as string 
			save in thepath --without template --with template
			close saving no
		end tell
	end tell
end repeat

Hey!
Awesome support! Thank you so much! The script does everything I asked for.

Just my bosses mind changed. She’d like to do it file per hotfolder now. Will evaluate details with her tomorrow (to make sure I won’t just waste my (and yours) time).
Have to find a different way to handle files including eps images anyway.