Hi. Have just upgraded to CS6 and have an issue with a script we use in production. The script exports a .ps file to a location but we are having to remove the .indd extension each time we use it (eg filename.indd.ps becomes filename.ps). The previous version of indesign we were able to save the file without it's .indd extension and when it was opened the extension stayed hidden. CS6 can save without the extension but when the file is open the extension is visible again. Any ideas? cheers
Hi Steve,
Can you please try the below JS code.
I am not tested the below code in CS6 just tested only CS5.5
var myDoc = app.activeDocument;
var myPath = myDoc.filePath;
var myNEWName = (myDoc.name.replace(".indd",".ps"));
var myDc = new File(myPath+"/"+myNEWName);
myDoc.save(myDc);
myDoc.saveACopy(myDc);
thx
csm_phil
hi,
well some code could have been nice ...
For general, you can use this handler which starts "system events"
Input alias & new suffix -> returns new filename
Code:
set thisWillBeTheNewFileName to my setFileName(choose file, "ps") --example usage
on setFileName(myAlias, myNewSuffix)
tell application "System Events"
set {myName, myExtension} to {name, name extension} of disk item (myAlias as text)
if myExtension is not "" then
set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, myExtension}
set myName to text 1 thru -2 of (text item 1 of myName)
end if
set newName to myName & "." & myNewSuffix
end tell
return newName
set AppleScript's text item delimiters to tid
end setFileName
Firing up System Events seems like overkill (and it's quite slow to launch), especially as you're using text item delimiters anyway. You could just use:
on changeExtension(oldPath, ext)
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set justName to text item -1 of oldPath
if justName contains "." then
set AppleScript's text item delimiters to {"."}
set newPath to text 1 thru text item -2 of oldPath
else
set newPath to oldPath
end if
set AppleScript's text item delimiters to saveTID
return newPath & "." & ext
end changeExtension
Of course if you're happy to use some outside help, my ASObjC Runner is quicker and easier than System Events:
tell application "ASObjC Runner" to set newPath to file path from oldPath replacing extension ext
Hi,
Shane Stanley wrote:
Firing up System Events seems like overkill (and it's quite slow to launch), especially as you're using text item delimiters anyway. You could just use:
of course you're right assuming a text path is send to the handler, System Events will handle text path or alias. As the poster couldn't show any source code it seemed safer ;-)
Have a nice day ![]()
-hans- wrote:
of course you're right assuming a text path is send to the handler, System Events will handle text path or alias.
That's a good point, but a simple "as string" will solve it in the first example.
The second example, using ASObjC Runner, will actually accept an alias, file, HFS path or even POSIX path.
North America
Europe, Middle East and Africa
Asia Pacific