Copy link to clipboard
Copied
Is there a script that generates a log file displaying The Indesign *User, Date, Time file location*. And if so can it generate a excel file? Also the Log File will need to be update and not overwritten.
Maybe something like this? Just the layout or if it cant be done in Excel can the log use tabs so when i paste it into excel it flows like this?
I'll add this script to my existing Information Script. via eventlistener to execute on export.
Thank You
...#targetengine 'onAfterExport'
var main = function() {
var ids ={};
var el = app.eventListeners.itemByName('onAfterExport'),
onAfterExportHandler = function(evt){
var doc = evt.parent, time;
if ( doc.constructor.name=="Document" ) {
if ( !ids[doc.id+"_"+evt.timeStamp] ) {
ids[doc.id+"_"+evt.timeStamp] = 1;
log ( evt );
}
}
};
!el.isValid && app.eventListeners.add('afterExport', onAfterExportHandler).name = 'onAfterExport';
}
var log = function (evt){
var headers = ["indesign user name"
Copy link to clipboard
Copied
The easiest way is to write the data to CSV-file and open it in Excel. I associated csv extension with Excel so it opens CSVes with double-clicking. Here's a quite similar script you can use as starting point for your script. However, it overwrites the CSV every time you run the script.
Here's the WriteToFile function that appends data if the file already exists:
function WriteToFile(text) {
var file = new File("~/Desktop/" + scriptName + ".txt");
file.encoding = "UTF-8";
if (file.exists) {
file.open("e");
file.seek(0, 2);
}
else {
file.open("w");
}
file.write(text);
file.close();
}
— Kas
Copy link to clipboard
Copied
#targetengine 'onAfterExport'
var main = function() {
var ids ={};
var el = app.eventListeners.itemByName('onAfterExport'),
onAfterExportHandler = function(evt){
var doc = evt.parent, time;
if ( doc.constructor.name=="Document" ) {
if ( !ids[doc.id+"_"+evt.timeStamp] ) {
ids[doc.id+"_"+evt.timeStamp] = 1;
log ( evt );
}
}
};
!el.isValid && app.eventListeners.add('afterExport', onAfterExportHandler).name = 'onAfterExport';
}
var log = function (evt){
var headers = ["indesign user name", "Time", "Date", "Output Location and Name", "Document Name", "Document path"];
var exportFile = File ( evt.fullName );
var f = File ( Folder.desktop+"/exports.csv" );
var fOk = f.exists;
var d = (new Date());
var m = d.getMonth()+1;
m<10 && m = "0"+m;
var hh = d.getHours();
var pm = hh>11;
pm && hh>12 && hh-=12;
hh<10 && hh = "0"+hh;
var mm = d.getMinutes();
mm< 10 && mm = "0"+mm;
var doc = evt.parent;
f.open('a');
!fOk && f.writeln ( headers.join(";") );
f.writeln([app.userName, hh+":"+mm+" "+(pm? "PM":"AM"), m+"/"+d.getDate()+"/"+d.getFullYear(), exportFile.fsName, doc.name, doc.properties.fullName? doc.fullName : "Not saved" ].join(";") );
f.close();
};
main();
Copy link to clipboard
Copied
This displays the proper information. But i cannot get it to separate into columns.
Copy link to clipboard
Copied
I don't have Excel myself but it might be related to separators. Try using .join(",") or .join("\t")
Copy link to clipboard
Copied
Ok i'll try that. Thank you.
Copy link to clipboard
Copied
This would work for me. But I'm trying to make it do all this stuff automatically for the other People in the office. I'm trying to make this as easy as possible. Because while its not a big deal most people will complain about opening a script selecting what to do and Exporting.
Copy link to clipboard
Copied
It's a startup script you can easily dispatch through all your users.
only hiccup is that the file might not accessible at some time if one is being writing into it through teh script.
Otherwise you need to write to a database.
Loic
Copy link to clipboard
Copied
What you gave me loic will work. All i have to do in excel is tell it where theres a ; to make a new column takes about 1 second to do. And i have yours added to the startup inside my other Script. I have it executing as before the export. That way i dont have to go to everyone's computer and add this. Also gives me flexibility if i add or change anything its automatic. The above comment was to Kasyan.