{"skills":[{"name":"Plan consistent names for a folder of archive scans","description":"Build a reversible rename list for scanned documents and flag collisions before touching any originals.","content":"# Plan consistent names for a folder of archive scans\n\nBuild a reversible rename list for scanned documents and flag collisions before touching any originals.\n\n## When to use this skill\n\n- Someone has a folder of scans with scanner or camera names, such as IMG_0042.JPG or scan001.tif, and wants consistent dated names.\n- An archive or family collection needs file names that sort by document date and include an item identifier.\n- Names are being changed on a case-insensitive drive, or two files need to swap names, and nothing may be overwritten.\n\n## When not to use it\n\n- Cataloguing or describing the documents. File names help retrieval; descriptions belong in a catalogue or metadata record.\n- Running the rename. This skill produces a dry-run manifest for the person or a script to apply after review.\n- Dating an undated document from its content. Mark the date unknown, or ask an archivist to assess it.\n\n## What you need\n\n- Current filenames, known document dates, document type, item identifiers and naming convention.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What naming convention should be used, such as YYYY-MM-DD_type_id.ext? Agreeing it first avoids renaming twice.\n- Where does each document's date come from: the date written on it, a catalogue record, or nowhere? The scan date is not the document date.\n- Which drive and operating system will hold the files? Windows, and macOS drives formatted as case-insensitive, treat names that differ only in case as the same file.\n- Are there other files in the destination folder that are not being renamed?\n\n## Method\n\n1. Fix the convention before proposing names: ISO 8601 dates (YYYY-MM-DD) so names sort by date, then document type, item identifier and extension, using only lowercase letters, digits, hyphens and the _ character, with no spaces or other punctuation.\n2. Take the date from the document or its catalogue record. If there is none, keep the date unknown and hold the file; never substitute the scan date or the file's modified date.\n3. Propose each new name in a side-by-side manifest: old name, new name and where each part came from. Keep the file's extension, in lowercase.\n4. Normalise names for comparison, by lowercasing and applying Unicode normalisation, then check for collisions among the proposed names and against existing files in the destination that are staying where they are.\n5. Hold every file involved in a collision, not just the second one, and say what detail would tell them apart, such as a sheet number or a distinct identifier.\n6. Tell apart a true collision (two files want the same final name) and a temporary conflict (a final name is currently held by another file in the batch). For swaps, cycles and case-only changes, plan a first pass to unique temporary names on the same volume, checked against the whole directory, then a second pass to the final names.\n7. Never overwrite a file outside the selection. Keep the manifest as the record of the change so it can be reversed.\n\n## Checks before you deliver\n\n- Two scans on one date can still be separate originals.\n- Lowercasing on a different filesystem can collapse distinct names.\n- Using the scan date because it is in the file metadata. It records when the copy was made, not when the document was written.\n- Renaming A to B before the existing B has moved, which overwrites B.\n- Using characters some systems reserve, such as a colon, slash or question mark, or ending a name with a space or full stop, which Windows does not support.\n\n## How to present the result\n\nStart with how many files can be renamed now and how many are held. Then give the manifest as a table: old name, proposed name and the source of the date. List held files with the reason and the detail needed to resolve each. If staging is needed, give the two-pass order explicitly. Hand back the manifest for review, not a script that has already run.\n\n## Worked example\n\n**Request:** Prepare a dry-run manifest.\n\n**Supplied material:**\n\n```text\nx001.JPG: letter dated 1964-10-02, id A7, scanned 2026-11-01. x002.JPG: receipt, id R9, no document date.\n```\n\n**Answer:** Proposed rename: x001.JPG \u2192 1964-10-02_letter_a7.jpg.\nHold x002.JPG. It is receipt R9, but its document date is unknown. The scan date cannot supply the missing date.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nFor the fixtures propose YYYY-MM-DD_kind_id.ext in lowercase with the supplied kind and ID. Return rename as an object old name to new, and hold as original names in input order for missing dates or collisions. Withhold all sides of a collision. If asked to flag staged renames, also return stage as original names that must first be moved to temporary names for the proposed two-phase plan.\n\n## Sources\n\n- [US National Archives: NARA Bulletin 2015-04, Appendix B, file naming](https:\/\/www.archives.gov\/records-mgmt\/bulletins\/2015\/2015-04-appendix-b.html): Advises platform-independent file and folder names using only letters a to z, digits 0 to 9, hyphens and the _ character, with no spaces, and keeping components such as dates in the same position in every name.\n- [US National Archives, Records Express: best practices for file naming](https:\/\/records-express.blogs.archives.gov\/2017\/08\/22\/best-practices-for-file-naming\/): Published by NARA's Chief Records Officer, it recommends ISO 8601 date notation (YYYY-MM-DD), unique and consistently structured names, leading zeros in sequence numbers and avoiding punctuation.\n- [Microsoft Learn: naming files, paths and namespaces](https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/fileio\/naming-a-file): Says not to assume case sensitivity, because names such as OSCAR, Oscar and oscar are the same by default, lists reserved characters and device names, and says names should not end with a space or full stop.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/archive-file-names\n","scope":"contextual","trigger_keywords":["Plan consistent names for a folder of archive scans","archive-file-names","archive file names","How should I rename these scanned photos so they sort by date?","How should I rename these scanned photos so they sort by date","rename these archive scans","archive file naming","rename my scanned documents"],"is_private":true,"is_active":true,"scripts":[{"name":"archive-file-names-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"archive-file-names-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: archive-file-names\ndescription: \"Plan a reversible rename of scanned documents to a dated naming convention, using the date on the document, and catch collisions and swap conflicts before any file is touched. Use when someone wants to rename a folder of scans, photos or digitised papers consistently.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/archive-file-names\n---\n\n# Plan consistent names for a folder of archive scans\n\nBuild a reversible rename list for scanned documents and flag collisions before touching any originals.\n\n## When to use this skill\n\n- Someone has a folder of scans with scanner or camera names, such as IMG_0042.JPG or scan001.tif, and wants consistent dated names.\n- An archive or family collection needs file names that sort by document date and include an item identifier.\n- Names are being changed on a case-insensitive drive, or two files need to swap names, and nothing may be overwritten.\n\n## When not to use it\n\n- Cataloguing or describing the documents. File names help retrieval; descriptions belong in a catalogue or metadata record.\n- Running the rename. This skill produces a dry-run manifest for the person or a script to apply after review.\n- Dating an undated document from its content. Mark the date unknown, or ask an archivist to assess it.\n\n## What you need\n\n- Current filenames, known document dates, document type, item identifiers and naming convention.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What naming convention should be used, such as YYYY-MM-DD_type_id.ext? Agreeing it first avoids renaming twice.\n- Where does each document's date come from: the date written on it, a catalogue record, or nowhere? The scan date is not the document date.\n- Which drive and operating system will hold the files? Windows, and macOS drives formatted as case-insensitive, treat names that differ only in case as the same file.\n- Are there other files in the destination folder that are not being renamed?\n\n## Method\n\n1. Fix the convention before proposing names: ISO 8601 dates (YYYY-MM-DD) so names sort by date, then document type, item identifier and extension, using only lowercase letters, digits, hyphens and the _ character, with no spaces or other punctuation.\n2. Take the date from the document or its catalogue record. If there is none, keep the date unknown and hold the file; never substitute the scan date or the file's modified date.\n3. Propose each new name in a side-by-side manifest: old name, new name and where each part came from. Keep the file's extension, in lowercase.\n4. Normalise names for comparison, by lowercasing and applying Unicode normalisation, then check for collisions among the proposed names and against existing files in the destination that are staying where they are.\n5. Hold every file involved in a collision, not just the second one, and say what detail would tell them apart, such as a sheet number or a distinct identifier.\n6. Tell apart a true collision (two files want the same final name) and a temporary conflict (a final name is currently held by another file in the batch). For swaps, cycles and case-only changes, plan a first pass to unique temporary names on the same volume, checked against the whole directory, then a second pass to the final names.\n7. Never overwrite a file outside the selection. Keep the manifest as the record of the change so it can be reversed.\n\n## Checks before you deliver\n\n- Two scans on one date can still be separate originals.\n- Lowercasing on a different filesystem can collapse distinct names.\n- Using the scan date because it is in the file metadata. It records when the copy was made, not when the document was written.\n- Renaming A to B before the existing B has moved, which overwrites B.\n- Using characters some systems reserve, such as a colon, slash or question mark, or ending a name with a space or full stop, which Windows does not support.\n\n## How to present the result\n\nStart with how many files can be renamed now and how many are held. Then give the manifest as a table: old name, proposed name and the source of the date. List held files with the reason and the detail needed to resolve each. If staging is needed, give the two-pass order explicitly. Hand back the manifest for review, not a script that has already run.\n\n## Worked example\n\n**Request:** Prepare a dry-run manifest.\n\n**Supplied material:**\n\n```text\nx001.JPG: letter dated 1964-10-02, id A7, scanned 2026-11-01. x002.JPG: receipt, id R9, no document date.\n```\n\n**Answer:** Proposed rename: x001.JPG \u2192 1964-10-02_letter_a7.jpg.\nHold x002.JPG. It is receipt R9, but its document date is unknown. The scan date cannot supply the missing date.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nFor the fixtures propose YYYY-MM-DD_kind_id.ext in lowercase with the supplied kind and ID. Return rename as an object old name to new, and hold as original names in input order for missing dates or collisions. Withhold all sides of a collision. If asked to flag staged renames, also return stage as original names that must first be moved to temporary names for the proposed two-phase plan.\n\n## Sources\n\n- [US National Archives: NARA Bulletin 2015-04, Appendix B, file naming](https:\/\/www.archives.gov\/records-mgmt\/bulletins\/2015\/2015-04-appendix-b.html): Advises platform-independent file and folder names using only letters a to z, digits 0 to 9, hyphens and the _ character, with no spaces, and keeping components such as dates in the same position in every name.\n- [US National Archives, Records Express: best practices for file naming](https:\/\/records-express.blogs.archives.gov\/2017\/08\/22\/best-practices-for-file-naming\/): Published by NARA's Chief Records Officer, it recommends ISO 8601 date notation (YYYY-MM-DD), unique and consistently structured names, leading zeros in sequence numbers and avoiding punctuation.\n- [Microsoft Learn: naming files, paths and namespaces](https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/fileio\/naming-a-file): Says not to assume case sensitivity, because names such as OSCAR, Oscar and oscar are the same by default, lists reserved characters and device names, and says names should not end with a space or full stop.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/archive-file-names\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/archive-file-names\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# The scan date came later\n\nPrepare a dry-run manifest.\n\n## Supplied material\n\nx001.JPG: letter dated 1964-10-02, id A7, scanned 2026-11-01. x002.JPG: receipt, id R9, no document date.\n\n## Worked answer\n\nProposed rename: x001.JPG \u2192 1964-10-02_letter_a7.jpg.\nHold x002.JPG. It is receipt R9, but its document date is unknown. The scan date cannot supply the missing date.\n\n## Reasoning\n\nThe scan date is not used to fill a missing document date.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"Prepare a dry-run manifest.\nReturn only the JSON specified in SKILL.md for this test.\n\nx001.JPG: letter dated 1964-10-02, id A7, scanned 2026-11-01. x002.JPG: receipt, id R9, no document date.\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"rename\": {\n        \"x001.JPG\": \"1964-10-02_letter_a7.jpg\"\n    },\n    \"hold\": [\n        \"x002.JPG\"\n    ]\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"The scan date is not used to fill a missing document date.\n"},{"path":"tests\/case-2\/request.txt","content":"Which files may be renamed?\nReturn only the JSON specified in SKILL.md for this test.\n\none.TIF: 1970-01-01 map id A. two.tif: 1970-01-01 map id a. Three.tif: 1970-01-01 map id B.\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"rename\": {\n        \"Three.tif\": \"1970-01-01_map_b.tif\"\n    },\n    \"hold\": [\n        \"one.TIF\",\n        \"two.tif\"\n    ]\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"The two proposed \u2018a\u2019 names would collide after normalisation.\n"},{"path":"tests\/case-3\/request.txt","content":"Give the dry-run manifest and flag staged renames. Stage all participants in a cycle before assigning final names.\nReturn only the JSON specified in SKILL.md for this test.\n\nCase-insensitive volume. 1960-01-01_letter_a.jpg actually contains a letter dated 1961-01-01, ID B. 1961-01-01_letter_b.jpg contains the letter dated 1960-01-01, ID A. Neither destination is occupied by an unselected file.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"rename\": {\n        \"1960-01-01_letter_a.jpg\": \"1961-01-01_letter_b.jpg\",\n        \"1961-01-01_letter_b.jpg\": \"1960-01-01_letter_a.jpg\"\n    },\n    \"hold\": [],\n    \"stage\": [\n        \"1960-01-01_letter_a.jpg\",\n        \"1961-01-01_letter_b.jpg\"\n    ]\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"Each document has a unique final name. Staging both first keeps the first rename from overwriting the second document.\n"}],"is_active":true,"is_approved":false}]}]}