I need to automatically rename links according to a specific key. Everything works until the file name contains "...%ef..."
Mac/Indesign replaces "%ef" with a colon - (from api: filePath - The file path (colon delimited on the Mac OS))
doc = app.activeDocument
links_list = doc.links
for(i=0;i<links_list.count();i++){
//[...some code...]
newKeyName[i] = links_list[i].name.replace(partOfOldName, newKey);
//[...some code...]
myFile = new File(links_list[k].filePath)
$.writeln(myFile.exists)//Console say - true. If name contains "...%ef..." - false
$.writeln(myFile.rename(newKeyName[i]))//...
}
I'm trying to use replace
if(myFile.name.indexOf(":")>0){
$.writeln(myFile.name)//Console say - example: aaa%efbbb.png > aaa:bbb.png
myFolder = myFile.path
myName = myFile.name
myName = myName.replace(":","%ef")
myFile = new File(myFolder+"/"+myName);
$.writeln(myFile.exists)//Console say - false.
$.writeln(myFile.name)//Console say - cut file name after "%ef" example: aaa%efbbb.png > bbb.png
}
I'm trying linkResourceURI - same effect or worst.
I want to rename link files containing any characters... on each system (mac/win). I can?
Try creating a File object based on its existing file path and replacing the old name with the new key. In this way you rename files containing special characters that is compatible with both Mac and Windows systems.
Try this: