Copy link to clipboard
Copied
I have a script ready that pushes a report to the folder as a text file.
But want it to use the InDesign document name in the dialog - at the moment it shows Untitled.
It's not critical, but how do I get the filename into the output file automatically?
Any ideas?
Hi @Eugene Tyson I strongly suspect I am misunderstanding your request, but otherwise...
var doc = app.activeDocument;
alert(doc.name.replace(/\.[^\.]+$/, ''));
- Mark
Ah thanks - I think I figured it out
var doc = app.activeDocument;
// get filename without extension
var baseName = doc.name.replace(/\.[^\.]+$/, "");
// suggest this as the default in the Save dialog
var reportFile = File.saveDialog("Save report as", baseName + ".txt");
Copy link to clipboard
Copied
Hi @Eugene Tyson I strongly suspect I am misunderstanding your request, but otherwise...
var doc = app.activeDocument;
alert(doc.name.replace(/\.[^\.]+$/, ''));
- Mark
Copy link to clipboard
Copied
Ah thanks - I think I figured it out
var doc = app.activeDocument;
// get filename without extension
var baseName = doc.name.replace(/\.[^\.]+$/, "");
// suggest this as the default in the Save dialog
var reportFile = File.saveDialog("Save report as", baseName + ".txt");
Find more inspiration, events, and resources on the new Adobe Community
Explore Now