I have tried for a couple of days to save the image file pathes of a QuarkXpress dokument into a text file.
No success
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
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