Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create snake_case_renamer_depth_one.py
Sure! Below is the generated `README.md` file for the program along with some explanations. The name of the file should be `rename_files_script.py` to reflect the purpose of the script. --- # File and Folder Renamer A Python script to rename files and folders in a specified directory to lowercase with underscores. ## Usage To use the script, run the following command in your terminal: ``` python rename_files_script.py <directory_path> ``` Replace `<directory_path>` with the path to the directory containing the files and folders you want to rename. ## Features - Converts file and folder names to lowercase. - Replaces spaces with underscores. - Ensures that each name is unique in the directory by appending an index if necessary. ## Prerequisites - Python 3.x - `argparse` module (included in the standard library) ## How It Works The script takes a directory path as a command-line argument and iterates through all the files and folders in the directory. For each item, it generates a new name by converting it to lowercase and replacing spaces with underscores. If the new name is different from the original name and already exists in the directory, the script generates a unique name by appending an index to the new name. The script then renames the item with the new name and continues the process for all items in the directory. ## Example Let's say we have a directory called `example_dir` with the following files and folders: ``` example_dir/ File 1.txt File 2.txt File 3.txt Folder 1/ Folder 2/ Folder 3/ ``` After running the script with the command: ``` python rename_files_script.py example_dir ``` The directory will be renamed as follows: ``` example_dir/ file_1.txt file_2.txt file_3.txt folder_1/ folder_2/ folder_3/ ``` All file and folder names have been converted to lowercase with underscores, and the names are unique within the directory. --- Remember to replace the `<directory_path>` placeholder in the README with the actual path to your directory when you distribute the script. The README provides clear instructions on how to use the script and explains its features and functionality.
- Loading branch information