Skip to content

Automate directory transcription and renaming via JSON files. Capture and store directory structure, then rename files and directories as needed. Ideal for bulk renaming, organisation, and documentation tasks, simplifying complex workflows efficiently.

License

Notifications You must be signed in to change notification settings

FREQ-EE/directory-transcriber-renamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Directory Transcriber and Renamer

Overview

This tool captures a directory's structure as a JSON file and allows controlled renaming of directories and files using the JSON. It can be used for documentation, reorganisation, and bulk renaming.

Features

  • Transcribe Directory Structure: Create a JSON representation of directories and files.
  • Editable JSON: Edit the JSON file for flexible renaming, compatible with other automation scripts.
  • Rename Directories and Files: Use the JSON transcription to rename directories and files.

Requirements

  • Python 3.6+
  • Terminal access

Installation

Clone the repository and ensure Python is installed.

$ git clone /~https://github.com/FREQ-EE/directory-transcriber-renamer.git
$ cd directory-transcriber-renamer

Usage

The script supports three steps:

  1. Transcribe Directory Structure
  2. Edit JSON File
  3. Rename Files/Directories Based on Transcription

1. Transcribing Directory Structure

Generate a JSON file representing the directory structure.

Run the script and select option A.

$ python directory-transcriber-renamer.py
  • Enter the directory path to transcribe.
  • Specify the output filename (default: directory_structure).
  • The JSON file will be saved in the transcriptions/ directory.

Example:

Choose an option:
A. Transcribe directories
B. Rename directories/files
Enter your choice (A/B): A
Enter the input directory path to transcribe: ~/Documents/example_folder
Enter the output file name (without extension, default: directory_structure): my_example_structure
Directory structure transcribed to transcriptions/my_example_structure.json

Generated JSON format:

{
    "": {
        "dirs": {
            "subfolder1": "",
            "subfolder2": ""
        },
        "files": {
            "file1.txt": "",
            "file2.txt": ""
        }
    },
    "subfolder1": {
        "dirs": {},
        "files": {
            "file3.txt": ""
        }
    }
}

2. Editing JSON File

Modify the JSON file to rename directories or files.

  • Open the JSON file located in the transcriptions/ directory.
  • Modify the values for dirs or files as needed.

Automating JSON Editing

The JSON file can be programmatically edited for renaming (e.g., translation, reformatting). This allows integration with automated workflows.

3. Renaming Directories and Files

Run the script and select option B to apply the renaming.

$ python transcribe.py

Example:

Choose an option:
A. Transcribe directories
B. Rename directories/files
Enter your choice (A/B): B
Enter the transcription filename (without extension): my_example_structure
Enter the base directory path where renaming should occur: ~/Documents/example_folder
Renamed file: ~/Documents/example_folder/file1.txt -> ~/Documents/example_folder/new_file1.txt
Renamed directory: ~/Documents/example_folder/subfolder1 -> ~/Documents/example_folder/new_subfolder1

Notes

  • Ensure the input directory matches the structure captured in the JSON file.
  • Verify the JSON file contents before renaming to avoid errors.

License

MIT License

About

Automate directory transcription and renaming via JSON files. Capture and store directory structure, then rename files and directories as needed. Ideal for bulk renaming, organisation, and documentation tasks, simplifying complex workflows efficiently.

Topics

Resources

License

Stars

Watchers

Forks

Languages