script for transfering path from jpg to tiff

I need some help to make an AppleScript (or Automator script) that in Photoshop can open a jpg-file (named xxx.jpg) from folder A,
and open a tif-file (named xxx.tif) from folder B.
Then move an included path from the opened jpg-file to the opened tif-file and save the tif with the path.

Then continue with the next jpg/tif set of files…

Anyone here who knows how to make this?

B

This (or a modification to this) might do what you want, if I’ve got it right


-- we assume all docs have same size and names and you're on CS2

set jF to choose folder -- sourse folder
set tF to choose folder -- destination folder

tell application "Finder"
	set {jFp, tFp} to {jF as string, tF as string}
	set sFilesList to files in jF
	repeat with sFile in sFilesList
		set {sFile, sFileName} to {sFile as alias, name of sFile}
		set tName to text 1 thru -5 of sFileName
		set tFile to (first file of tF whose name is tName & ".tif") as alias
		
		tell application "Adobe Photoshop CS2"
			close every document saving no
			set display dialogs to never
			open sFile
			set p to properties of path item 1 of current document
			-- if there's more than one path then access it my it's name
			close current document
			open tFile
			-- the 'duplicate path item' command crashes my CS2 - don't know why -, so I use this instead witch works fine
			ignoring application responses
				-- otherwise it will error,as, the container of the properties is not the current doc. You also skip a lot of boring variable access and transfers
				make new path item at current document with properties p
			end ignoring
			close current document saving yes
		end tell
	end repeat
end tell

Yannis

Sorry for bringing this old topic back, but I have the same question as “bjorn”.

I tried the scirpt that Yannis wrote but can’t make it work. I’m a total newbie to applescript but I did at least understand that I should change cs2 to cs5 (which I’m using).

What I have done is to open the script, then run it and in the first dialog box I chose a folder containing two jpg’s with clipping paths, and in the second a folder containg two tif files without paths

Then the script-program is warning me that photoshop can’t find the object at
“open sFile”

Can somebody help me with this, then I would be extremely grateful

cheers

Ok, I kind of solved the problem by making two photoshop droplets, one that will copy a path and one that will paste, then I made two automator-actions one that opens something with the first droplet and yeah one that opens something with the second. I named the automator actions to “copypath” and “pastepath” saved them as applications in the application folder and then changed somethings in the applescript here above, this is my version of it


-- we assume all docs have same size and names and you're on CS2

set jF to choose folder -- sourse folder
set tF to choose folder -- destination folder

tell application "Finder"
	set {jFp} to {jF as string}
	set {tFp} to {tF as string}
	set sFilesList to files in jF
	repeat with sFile in sFilesList
		set {sFile, sFileName} to {sFile as alias, name of sFile}
		set tName to text 1 thru -5 of sFileName
		set tFile to (first file of tF whose name is tName & ".tif") as alias
		
		
		
		tell application "copypath"
			open sFile
		end tell
		
		delay 3
		
		
		
		tell application "pastepath"
			open tFile
		end tell
		
		delay 3
		
		
		
	end repeat
end tell

but it would feel better to make it more simple, like the original script. Any ideas?

It’s been some time since I’ve seen this in AppleScript form. (Probably could do with a tidy up). It does NOT include the batch part of the process but creating 2 lists of files then looping should NOT prove a problem. This just shows how to transfer from one doc to the other. Should be a pointer anyhow.

set File_A to choose file with prompt "Please select your \"JPEG\" File." without invisibles
set File_B to choose file with prompt "Please select your \"TIFF\" File." without invisibles
--
tell application "Adobe Photoshop CS2"
	set display dialogs to never
	set User_Rulers to ruler units of settings
	set ruler units of settings to pixel units
end tell
--
tell application "Adobe Photoshop CS2"
	activate
	open File_A
	set Doc_A to the current document
	tell Doc_A
		if resolution ≠ 72 then
			resize image resolution 72 resample method none
		end if
		if exists path items then
			set {Path_Names, Path_Data, Path_Kind} to ¬
				{name of every path item, entire path of every path item, kind of every path item}
			-- Never did get around to putting this check in
			-- set {Pixel_Height, Pixel_Width, PAR} to ¬
			-- {height, width, pixel aspect ratio}
		else
			set {Path_Names, Path_Data, Path_Kind} to {{}, {}, {}}
			close saving no
		end if
	end tell
	open File_B
	set Doc_B to the current document
	tell Doc_B
		if Path_Names ≠ {} then
			if resolution ≠ 72 then
				set {Re_Size, Orig_Res} to {true, resolution}
				resize image resolution 72 resample method none
			else
				set Re_Size to false
			end if
			repeat with i from 1 to count Path_Names
				if not (exists path item (item i of Path_Names)) then
					set Re_Name to false
					make new path item with properties ¬
						{name:(item i of Path_Names), entire path:(item i of Path_Data), kind:normal}
				else
					set Re_Name to true
					make new path item with properties ¬
						{name:(item i of Path_Names) & "_New", entire path:(item i of Path_Data), kind:normal}
				end if
			end repeat
			repeat with i from 1 to count Path_Kind
				if (item i of Path_Kind) = clipping then
					if Re_Name is false then
						make clipping path path item (item i of Path_Names) flatness 0.3
					else
						make clipping path path item ((item i of Path_Names) & "_New") flatness 0.3
					end if
				end if
			end repeat
			if Re_Size is true then
				resize image resolution Orig_Res resample method none
			end if
		else
			close saving no
		end if
	end tell
end tell
--
tell application "Adobe Photoshop CS2"
	set ruler units of settings to User_Rulers
end tell

tried that script also and still got the samething going wrong, photoshop couldn’t open the file, strange

edit: searched a bit and found the same problem in this thread
http://macscripter.net/viewtopic.php?id=34029

maybe I can fix it now…:slight_smile:

So now I have a little less filthy script, it suits my needs and I think I made OK for being a total newbie


set jF to choose folder with prompt "Choose JPG-Folder" -- source folder
set tF to choose folder with prompt "Choose TIF-Folder" -- destination folder

tell application "Finder"
	set {jFp, tFp} to {jF as string, tF as string}
	set sFilesList to files in jF
	repeat with sFile in sFilesList
		set {sFile, sFileName} to {sFile as string, name of sFile}
		set tName to text 1 thru -5 of sFileName
		set tFile to (first file of tF whose name is tName & ".tif") as string
		
		tell application "Adobe Photoshop CS5"
			activate
			close every document saving no
			set display dialogs to never
			open alias sFile
			select path item 1 of current document
			copy								-- I don't get this about recording data
			close current document saving no
			open alias tFile
			tell application "System Events"			-- couldn't get paste-command to work
				keystroke "v" using command down
			end tell
			close current document saving yes
		end tell
	end repeat
end tell