Have the keywords be user defined at the start of script.
Created with : https://bulkrename.software/js/
- Code: Select all
// User-defined list of keywords to look for in each PDF
var keywords = ['Google', 'Microsoft', 'Apple', 'Amazon'];
// Default to keeping the original name
newName = name;
// Only examine PDF files
if (ext.toLowerCase() === 'pdf') {
// Loop through each keyword and stop at first match
for (var i = 0; i < keywords.length; i++) {
var kw = keywords[i];
// fileMatch returns the matching line or null if not found
if (fileMatch(kw)) {
// Prefix the filename (without extension) with the keyword and an underscore
newName = kw + '_' + name;
break;
}
}
}
// Examples:
// If name = "report.pdf" and the PDF contains "Google", then newName = "Google_report"
// If name = "summary.pdf" and no keywords are found, newName remains "summary"
- Code: Select all