Error in obtaining file path of Photoshop document

Hi Y’all

This should be a very simple script but it’s not working. I just want the file path of an open Photoshop document. This code I have is this:

tell application "Adobe Photoshop CS5.1"
	set thisDoc to the current document
		set docFilePath to file path of thisDoc -- dodgy line
end tell

It doesn’t work if the file has had any work done to it and then saved. It only works if the file is open without any changes. The error I get is

Any suggestions or work arounds appreciated

Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)

Hi,

try this as a workaround, the result is a file URL


tell application "Adobe Photoshop CS3"
	activate
	set docName to name of current document
end tell

tell application "System Events"
	tell process "Adobe Photoshop CS3"
		tell (first window whose title starts with docName)
			set fileURL to value of attribute "AXDocument"
		end tell
	end tell
end tell

Hi,

another workaround:

tell application “Adobe Photoshop CS5.1”
try
set docFilePath to file path of current document
on error msg number errnum
if errnum is 8103 then
display dialog “This document need to be saved.” buttons {“OK”} default button 1
else
display dialog msg buttons {“OK”} default button 1
end if
end try
end tell

Hagi

Thanks guys

I think Stephan’s approach is going to work for me. I can process that URL into a file path later in my script. When I finish it I will post it here.

Thanks again