Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

relink image of selection in indesign cs script



Hi, 

I am trying to get the below image relinking script to work and almost have 
it done. What does not seem to work is the last part of it which is marked 
with *****.

Any ideas how I can refer to the image properly - the problem seems to be 
with the variable mylink. Any ideas how I can define it properly.

Best, Patrik

PS: Here is the code

global pathparts, nameparts, rename, mylabel, linkcount

on bust(s)
	set text item delimiters to ":"
	set pathparts to text items of s
	set text item delimiters to "."
	set nameparts to text items of last item of pathparts
	return {pathparts, nameparts}
end bust

on rename(oldpath)
	set bothlists to bust(oldpath)
	set extension to last item of item 2 of bothlists
	set pathpart to items 1 thru -2 of item 1 of bothlists
	--set newfilename to my mylabel & my Mychoice
	--set newfilename to newfilename & "." & extension
	set text item delimiters to ":"
	return (pathpart as string) & ":" & (my Mychoice as string)
end rename
--	bust (mypath)

--return (pathpart as string) & ":" & newfilename
on JustName(s)
	set text item delimiters to ":"
	return last text item of s
end JustName

--the following basically relinks 
set myerrorname to {}

tell application "InDesign CS"
	set myselection to selection
	set theSelection to item 1 of selection
	set theClass to class of theSelection
	if theClass is in {image, PDF} then
		-- if the image is selected by direct tools 
		set theSelection to parent of theSelection
	end if
	
	-- try to get the file path of the item and name then opt it for 
change
	set theFilePathOfImage to file path of item link of graphic 1 of 
theSelection
	set myimage to name of item link of graphic 1 of theSelection
	display dialog "Rename the below file name as you wish." default 
answer "" & (myimage as string) default button 2 with icon 1
	copy (text returned of the result) to Mychoice
	set mylink to item link of graphic 1 of selection
	
	try -- this actually renames the image in finder
		tell application "Finder" to set name of file 
theFilePathOfImage to Mychoice
	end try
	try -- this gets new path for the image
		set MyPath to (theFilePathOfImage as string)
		set mynewpath to my rename(MyPath)
		set mynewname to mynewpath as string
	end try
	relink the mylink to mynewname -- ******this is meant to relink the 
image to the new one
	update the mylink
end tell

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.