-
Notifications
You must be signed in to change notification settings - Fork 6
rename_to_snake_case.ps1
Corey Watson edited this page Dec 19, 2025
·
1 revision
Recursively rename all files and folders to snake_case format.
Recursively renames all files and folders in a directory to snake_case format. Converts spaces, hyphens, and other non-alphanumeric characters to underscores and lowercases all characters.
Recursively renames all files and folders in a directory to snake_case format. Converts spaces, hyphens, and other non-alphanumeric characters to underscores and lowercases all characters.
- Windows 10/11
- Write permissions to target directory
-
TargetPath: Directory path to process (recursive)
- Converts to lowercase
- Replaces non-alphanumeric characters with underscores
- Trims leading/trailing underscores
- Processes child items first (bottom-up) to avoid path issues
- Hardcoded values (target directory path)
- Validates target directory exists
- Gets all files and folders recursively
- Reverses list (process children before parents)
- Renames each item to snake_case if different
- Reports each rename operation
- No secrets in logs
- Only renames files/folders, does not modify content
- Cannot be undone - backup important directories first
- 0: Success
- 1: Failure
[ INPUT VALIDATION ]
--------------------------------------------------------------
Target Path : C:\Users\Example\Documents\MyFolder
[ OPERATION ]
--------------------------------------------------------------
Processing 15 items...
Renamed "My File.txt" to "my_file.txt"
Renamed "Another-File.pdf" to "another_file.pdf"
Renamed "Sub Folder" to "sub_folder"
[ RESULT ]
--------------------------------------------------------------
Status : Success
Renamed : 12 items
Skipped : 3 items (already snake_case)
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
- 2025-11-29 v1.0.0 Initial Style A implementation
- View Script Source
- Scripts - Back to script index