CDT Automation & Scripting 2 — Questions and Answers
Question 1: Which scripting approach is BEST for automating repetitive document conversions across hundreds of files in a watch folder?
- Manual batch rename using the OS file manager
- An event-driven script that monitors the folder and triggers conversion on new file arrival (Correct answer)
- Scheduling a single conversion command to run once per week
- Using copy-paste macros recorded in the word processor
Correct answer: An event-driven script that monitors the folder and triggers conversion on new file arrival
Event-driven folder-watch scripts process files immediately upon arrival, making them ideal for high-volume unattended conversion pipelines.
Question 2: In a document automation script, what is the purpose of a 'template variable' or 'merge field'?
- To lock a section of the document from editing
- To act as a placeholder that is replaced with dynamic data at runtime (Correct answer)
- To define the page margins of the output document
- To embed a digital signature in the footer
Correct answer: To act as a placeholder that is replaced with dynamic data at runtime
Template variables are placeholders (e.g., {{CustomerName}}) that the scripting engine replaces with actual data when generating the final document.
Question 3: A Zonal OCR script reads invoices but misidentifies the vendor name when the logo shifts position between vendors. What is the MOST appropriate fix?
- Increase the DPI setting on the scanner
- Switch from fixed-zone OCR to anchor-relative or AI-based field extraction (Correct answer)
- Convert all invoices to grayscale before processing
- Reduce the confidence threshold to accept more results
Correct answer: Switch from fixed-zone OCR to anchor-relative or AI-based field extraction
Anchor-relative extraction locates a field relative to a nearby text anchor (e.g., 'Vendor:') rather than an absolute page coordinate, handling layout variation.
Question 4: When automating PDF form data extraction with a script, which data format is most commonly used to export the collected field values for downstream processing?
- BMP image file
- FDF or XFDF (Correct answer)
- PostScript stream
- ICC color profile
Correct answer: FDF or XFDF
FDF (Forms Data Format) and XFDF (XML Forms Data Format) are the standard PDF specifications for exporting and importing form field values.
Question 5: A document workflow script must apply a Bates stamp to each page of a multi-volume legal set, continuing the sequence across volumes. Which programming concept is essential?
- Recursive file deletion
- Persistent counter state shared or passed between script runs (Correct answer)
- Random number generation
- Base64 encoding of page images
Correct answer: Persistent counter state shared or passed between script runs
Bates numbering must be sequential across volumes, so the script must persist the last-used counter (in a file, database, or argument) and resume from it for each new volume.
Question 6: Which regular expression pattern would correctly match a US Social Security Number in the format NNN-NN-NNNN for redaction automation?
- \d{3}-\d{2}-\d{4} (Correct answer)
- \w{3}-\w{2}-\w{4}
- \d{9}
- [0-9]{3}.[0-9]{2}.[0-9]{4}
Correct answer: \d{3}-\d{2}-\d{4}
\d{3}-\d{2}-\d{4} matches exactly three digits, a hyphen, two digits, a hyphen, and four digits — the standard SSN format.
Question 7: In document automation, what does 'idempotency' mean for a script that publishes documents to a content repository?
- The script compresses each document before upload
- Running the script multiple times produces the same end state without unintended duplicates or side effects (Correct answer)
- The script automatically increments version numbers
- The script requires administrator credentials to run
Correct answer: Running the script multiple times produces the same end state without unintended duplicates or side effects
An idempotent script can be safely re-run (e.g., after a failure) because it checks existing state and only makes changes that are still needed, avoiding duplicates.
Which scripting approach is BEST for automating repetitive document conversions across hundreds of files in a watch folder?