Highlighted

Indesign Script Log file generation

Participant ,
Sep 19, 2020

Copy link to clipboard

Copied

Hi Everyone,

Could you please give the functionality for generating the log file for Batch Process, to append the process completed files names in the folder and also report to stop the script if choose the wrong folders.

 

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi raghav,

You can use Adobe File/ Folder API to create a log file in your existing script. Here is the sample snippet to create a file and append new data. You can modify it as per your current script and logs.

var file = new File(Folder.myDocuments + "/log.txt");
if (file.exists) {
    file.open("a");
    var newData = "New Data"
    file.write(newData);
    file.close();
} else {
    var data = "Sample Data\n"
    file.open("w");
    file.write(data);
    file.close();
}

When you run the above script for the first time, it will write "Sample Data" to the text file named as "log.txt" inside folder Documents. When you exceute the script second time, since file is alreday exists, it will append new data, here "New Data" in the new line.

 

So you can use this sample to include in your existing script.

TOPICS
Scripting

Views

104

Likes

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

Indesign Script Log file generation

Participant ,
Sep 19, 2020

Copy link to clipboard

Copied

Hi Everyone,

Could you please give the functionality for generating the log file for Batch Process, to append the process completed files names in the folder and also report to stop the script if choose the wrong folders.

 

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi raghav,

You can use Adobe File/ Folder API to create a log file in your existing script. Here is the sample snippet to create a file and append new data. You can modify it as per your current script and logs.

var file = new File(Folder.myDocuments + "/log.txt");
if (file.exists) {
    file.open("a");
    var newData = "New Data"
    file.write(newData);
    file.close();
} else {
    var data = "Sample Data\n"
    file.open("w");
    file.write(data);
    file.close();
}

When you run the above script for the first time, it will write "Sample Data" to the text file named as "log.txt" inside folder Documents. When you exceute the script second time, since file is alreday exists, it will append new data, here "New Data" in the new line.

 

So you can use this sample to include in your existing script.

TOPICS
Scripting

Views

105

Likes

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
Sep 19, 2020 0
Adobe Community Professional ,
Sep 19, 2020

Copy link to clipboard

Copied

By 'the batch process' you mprobably mean the script you quoted in full in another thread. Try the script's authors, they're the ones best suited to add functionality to the script.

P.

Likes

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
Reply
Loading...
Sep 19, 2020 0
Adobe Community Professional ,
Sep 21, 2020

Copy link to clipboard

Copied

Hi raghav,

You can use Adobe File/ Folder API to create a log file in your existing script. Here is the sample snippet to create a file and append new data. You can modify it as per your current script and logs.

var file = new File(Folder.myDocuments + "/log.txt");
if (file.exists) {
    file.open("a");
    var newData = "New Data"
    file.write(newData);
    file.close();
} else {
    var data = "Sample Data\n"
    file.open("w");
    file.write(data);
    file.close();
}

When you run the above script for the first time, it will write "Sample Data" to the text file named as "log.txt" inside folder Documents. When you exceute the script second time, since file is alreday exists, it will append new data, here "New Data" in the new line.

 

So you can use this sample to include in your existing script.

Best regards

Likes

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
Reply
Loading...
Sep 21, 2020 2
Contributor ,
Sep 21, 2020

Copy link to clipboard

Copied

If you use .csv instead of .txt, it's easy to open your log file with Excel for filtering and sorting.

 

Bob

Likes

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
Reply
Loading...
Sep 21, 2020 1