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.
- 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.
- Python 3.6+
- Terminal access
Clone the repository and ensure Python is installed.
$ git clone https://github.com/FREQ-EE/directory-transcriber-renamer.git
$ cd directory-transcriber-renamerThe script supports three steps:
- Transcribe Directory Structure
- Edit JSON File
- Rename Files/Directories Based on Transcription
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": ""
}
}
}Modify the JSON file to rename directories or files.
- Open the JSON file located in the
transcriptions/directory. - Modify the values for
dirsorfilesas needed.
The JSON file can be programmatically edited for renaming (e.g., translation, reformatting). This allows integration with automated workflows.
Run the script and select option B to apply the renaming.
$ python transcribe.pyExample:
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
- Ensure the input directory matches the structure captured in the JSON file.
- Verify the JSON file contents before renaming to avoid errors.
MIT License