• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trouble with accented letters

Explorer ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

Hi Community,

Here's a simple script to change extension links from uppercase to lower and relink.

Everything seems right but I'm in trouble with accented letters in link name.

I know it's a path problem and i've tryied with decodeURI() but no way.

Thanks in advance

Mario

 

var myLinks = app.activeDocument.links;

for (i = 0; i < myLinks.length; i++) {
 
var nomeLink = myLinks[i].name;
var extPosizione = nomeLink.lastIndexOf(".");
var extLink = nomeLink.slice(extPosizione);
var nomeNoExt = nomeLink.slice(0, extPosizione);

if (extLink == extLink.toUpperCase()) {
var nomeOrExt = nomeNoExt + "x" + extLink.toLowerCase();

File(myLinks[i].filePath).rename(nomeOrExt);
var nuovoLink = new File(myLinks[i].filePath.replace(nomeLink, nomeOrExt));
myLinks[i].relink(nuovoLink);
myLinks[i].update();
} else {}
}
TOPICS
Scripting

Views

288

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 14, 2021 Jun 14, 2021

Yes Peter, I'm workin' on mac.

Thanks for your reply. I work around it and it seems do it well (I hope).

 

var myLinks = app.activeDocument.links;
 
for (i = 0; i < myLinks.length; i++) {
 
var nomeLink = myLinks[i].name;
var extPosizione = nomeLink.lastIndexOf(".");
var extLink = nomeLink.slice(extPosizione);
var nomeNoExt = nomeLink.slice(0, extPosizione);

if (extLink == extLink.toUpperCase()) {

var nomeOrExt = nomeNoExt + "x" + extLink.toLowerCase();

File(myLinks[i].filePath).rename(nomeOrExt)
var nuovoLin
...

Votes

Translate

Translate
Community Expert ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

If you work on a Mac, the problem may be that the Mac OS decomposes accented characters (into the base character and the accent) in file and folder names. I don't use a Mac and I've no idea how to work around it. Maybe a Mac user has an idea.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

LATEST

Yes Peter, I'm workin' on mac.

Thanks for your reply. I work around it and it seems do it well (I hope).

 

var myLinks = app.activeDocument.links;
 
for (i = 0; i < myLinks.length; i++) {
 
var nomeLink = myLinks[i].name;
var extPosizione = nomeLink.lastIndexOf(".");
var extLink = nomeLink.slice(extPosizione);
var nomeNoExt = nomeLink.slice(0, extPosizione);

if (extLink == extLink.toUpperCase()) {

var nomeOrExt = nomeNoExt + "x" + extLink.toLowerCase();

File(myLinks[i].filePath).rename(nomeOrExt)
var nuovoLink = decodeURI(File(myLinks[i].filePath));
var newLink = nuovoLink.substring(0, nuovoLink.lastIndexOf('/'));
myLinks[i].relink(File(newLink + "/" + nomeOrExt));
myLinks[i].update();
} else { }
}

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines