03 / File scripts

Batch the boring. Keep the originals.

File scripts can save a hundred clicks and make a hundred mistakes. A readable preview is part of the tool, especially when you are changing names or moving files.

Describe the selection rule

Write down the allowed directory, file extensions, and whether subfolders are included. Use a small fixture folder containing disposable copies. Include an unrelated file so you can verify that the script ignores it. Tell the assistant which operating system and shell you actually use; path handling should match that environment.

Separate planning from changing

Ask for a dry-run mode that prints each source and proposed destination without modifying either. Detect duplicate destinations and pre-existing files before applying a batch. A naming rule that looks unique on paper can still collide with existing output or a filename whose capitalization differs.

Verify the entire batch

Check the number of selected files against your expectation. Apply the script to the fixture folder, compare contents, and inspect its exit status after a deliberate failure. For work you cannot easily recreate, keep a separate backup. A log of attempted actions helps diagnosis; it is not a substitute for retaining the original data.

A brief to adapt
Design a dry-run-first file renamer for a fixture directory. List candidate changes, reject destination collisions, and ignore subfolders. Explain platform assumptions before writing code.