Copy link to clipboard
Copied
Hello everybody,
Regarding a jsx file
1. For an export from Indesign to JPEG, how to name JPEG files with a specific name wich is the 13 first characters (EAN) among the 14 first of every Indesign files name :
9782340-046337_COUV_2022_02_24.indd
becomes
9782340046337.jpg
2. And then save the export file on the desktop without changing the path on every machine
Thanks a lot for your help
Copy link to clipboard
Copied
You meant the first 14 characters, correct? Not the first 13.
jpgName = app.activeDocument.name.replace (/(.{14}).+/, '$1.jpg');
or perhaps
jpgName = app.activeDocument.name.replace (/^([-\d]+).+/, '$1.jpg')
which amounts to 'all digits and dashes from the start of the string', so you needn't worry about how many characters you want to catch.
> And then save the export file on the desktop without changing the path on every machine
What exactly do you mean by 'witout changing the path'? The desktop is its own path.
Copy link to clipboard
Copied
Hello Peter,
thanks for your quick answer.
For the moment I have that :
Copy link to clipboard
Copied
You need .substring(0,14) to get the file name correct.
The path on any computer's desktop is ~/Desktop/, so you would use
File("~/Desktop/" + doc.name.substring(0,14) + ".jpg"),
Copy link to clipboard
Copied
OK thanks.
So I have 9782340-046337.jpg on the desktop, but what I want is 9782340046337.jpg, 13 digits without the dash…
🙂
Copy link to clipboard
Copied