The clipboard content => text file

I have tried for a couple of days to save the image file pathes of a QuarkXpress dokument into a text file.
No success :frowning:

This is how far my script goes:

tell application "QuarkXPress Passport"
	tell document 1
		get file path of images as string
	end tell
end tell

But how do I save the file pathes as a text file on my desktop?
Do I need to get the results from the script into the clipboard first?
Is there any wise person out there who knows…?

Best regards
Jonas Bohlin

tell application "QuarkXPress Passport"
	tell document 1
		get file path of images as string
	end tell
end tell

what does

get file path of images as string

return?
a list like {“Path_Of_Image_1”,“Path_Of_Image_2”,“Path_Of_Image_3”} ?

If it is a list like above try this:

tell application "QuarkXPress Passport"
	tell document 1
		set theimagepaths to get file path of images as string
	end tell
end tell
set the_file to choose file name default name "imagepaths.txt" default location (path to desktop folder)
try
	open for access the_file with write permission
	set eof of the_file to 0
	write (theimagepaths) to the_file starting at eof as list
	close access the_file
on error
	try
		close access the_file
	end try
end try

YES!!! Mr life saver :smiley:

I have modified your script and now it looks like this:

tell application "QuarkXPress Passport"
	tell document 1
		set theimagepaths to get file path of images as string
	end tell
end tell

set the_file to "Macintosh HD:Users:louise:Desktop:images:Image_pathes.txt"
try
	open for access the_file with write permission
	set eof of the_file to 0
	write (theimagepaths) to the_file starting at eof as list
	close access the_file
on error
	try
		close access the_file
	end try
end try

The results in the text file now looks like:

listSTXT∏dle2STXT®ktxtTEXTrMacintosh HD:Users:louise:Desktop:images:Bowling.EPSCan’t make Macintosh HD:Users:louise:Desktop:images:Basket.EPSkstystyl

As you can see there are two images in the QuarkXpress dokument and they are surrounded by som irrelevant text. Is it possible to delete that text and also get the two images pathes in separate lines?

Thanks a million!!!

The following will address your two concerns:


tell application "QuarkXPress Passport"
	tell document 1
		set theOldDelimiters to AppleScript's text item delimiters
		set AppleScript's text item delimiters to return
		set theImagePaths to the file path of images as string  -- "as string" will now convert each file path to a string separated by a return
		set AppleScript's text item delimiters to theOldDelimiters
	end tell
end tell

set theFile to "Macintosh HD:Users:louise:Desktop:images:Image_paths.txt"
try
	open for access theFile with write permission
	set eof of theFile to 0
	write (theImagePaths) to theFile starting at eof -- removed "as list" which was causing the irrelevant text
	close access theFile
on error errorMessage
	try
		close access theFile
	end try
	error errorMessage -- show the error so the user knows what is going on!
end try

A hug to my helpers!!!