change filepath mac to window

Hi,

I am working on a Indesign document. I need to change the filepaths to a windows environment.

I thought that it was easy… just changing the “:” to “/” but :frowning:

who can help me??


tell application "Adobe InDesign CC"
	set oldParam to check links at open of linking preferences
	set check links at open of linking preferences to false
	activate
	if active book exists then
	else
		set GetParentPath to ((choose file with prompt "Kies een Indesignbook:" of type "IDb5.5"))
		open GetParentPath
		delay 1
	end if
end tell
tell application "Adobe InDesign CC"
	tell active book
		set fileList to full name of book contents
	end tell
	
	repeat with aFile in fileList
		set theDoc to open aFile
		set myDocument to active document
		tell myDocument
			set listOfLinks to (every link of myDocument)
			
			repeat with m from 1 to count listOfLinks
				set thisLink to item m of listOfLinks
				set ASTID to AppleScript's text item delimiters -- Store settings
				set TempPath to file path of thisLink as string
				set AppleScript's text item delimiters to ":" -- Everything splits at this character
				set TempPathBits to text items of TempPath
				repeat with i from 1 to count TempPathBits
					
					set item i of TempPathBits to TempPathBits & "/"
				end repeat
				
				set linkPath to items 1 thru i of TempPathBits as string
				
				set AppleScript's text item delimiters to "/" -- Everything splits at this character
				set NewLinkPath to items 1 thru m of TempPath -- set new path
				--relink thisLink to file NewLinkPath
				log NewLinkPath
				
			end repeat
			close theDoc saving yes
			
		end tell
	end repeat
	set check links at open of linking preferences to oldParam
end tell
end

Two problems:

  • the separator in Windows is '', not ‘/’; in A/S it must be escaped with a backslash
  • you have to prepend a drive letter, which may be unknown

Otherwise, this should work:

set TempPath to file path of thisLink as text
set AppleScript's text item delimiters to ":" -- Everything splits at this character
set TempPath to text items 2 thru end of TempPath -- drop drive name
set AppleScript's text item delimiters to "\\" -- escaping the backslash
set NewLinkPath to text items of TempPath as text -- set new path
set AppleScript's text item delimiters to "" -- Setting them back to default value
set NewLinkPath to "c:\\" & NewLinkPath-- prepend drive letter, with (escaped) backslash
display dialog result -- to show it worked
-- (output in Events pane is misleading)

thanks Alastor,

how can I link the image to the new path?

I know nothing of Indesign, so I have no idea…

But most obvious would be to reverse this:

set TempPath to file path of thisLink as text

to this:

set file path of thisLink to NewLinkPath

Indesign’s dictionary should tell you if that’s about right.

I still can’t relink… :frowning:

That doesn’t tell us much.
Did you consult ID’s dictionary?