feat: field rename multiple files
This commit is contained in:
parent
9573291582
commit
19eaf2d664
@ -20,7 +20,8 @@ Deno >=2.2 (not required if downloading .exe)
|
||||
|
||||
### Deno install
|
||||
|
||||
`deno task install` -> installs as global command `checkfields`
|
||||
`deno install -g --allow-read --allow-write --allow-net --allow-env jsr:@bearmetal/pdf-tools`
|
||||
-> installs as global command `pdf-tools`
|
||||
|
||||
### Compile
|
||||
|
||||
|
@ -103,13 +103,19 @@ class RenameFields implements ITool {
|
||||
[pdfPath, pattern, change] = await forceArgs(
|
||||
[pdfPath, pattern, change],
|
||||
[
|
||||
["Please provide path to PDF:", (p) => !!p && p.endsWith(".pdf")],
|
||||
[
|
||||
"Please provide path to PDF (comma separated for multiple):",
|
||||
(p) => !!p && p.endsWith(".pdf"),
|
||||
],
|
||||
"Please provide search string:",
|
||||
"Please provide requested change:",
|
||||
],
|
||||
this.block,
|
||||
);
|
||||
|
||||
const paths = pdfPath.split(",");
|
||||
|
||||
for (const pdfPath of paths) {
|
||||
const patternRegex = new RegExp(pattern);
|
||||
|
||||
const pdf = await loadPdf(pdfPath);
|
||||
@ -149,6 +155,7 @@ class RenameFields implements ITool {
|
||||
await savePdf(pdf, path || pdfPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
export default new RenameFields();
|
||||
|
||||
if (import.meta.main) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user