• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
relink image of selection in indesign cs script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

relink image of selection in indesign cs script


  • Subject: relink image of selection in indesign cs script
  • From: "Patrik B." <email@hidden>
  • Date: Wed, 7 Jun 2006 15:01:57 -0700

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: relink image of selection in indesign cs script
      • From: Shane Stanley <email@hidden>
  • Prev by Date: ANNOUNCE: Property List Tools 1.0.6
  • Next by Date: Re: relink image of selection in indesign cs script
  • Previous by thread: ANNOUNCE: Property List Tools 1.0.6
  • Next by thread: Re: relink image of selection in indesign cs script
  • Index(es):
    • Date
    • Thread