=
) only—let’s explore your options carefully.[B]os[/B]
(this is part of the Python standard library, so no separate installation is needed).rename_folders.py
.import os
# Change this to your target folder
music_folder = r"C:\MUSIC2025"
# Loop through every folder in the provided directory
for folder_name in os.listdir(music_folder):
folder_path = os.path.join(music_folder, folder_name)
# Ensure we're only working with directories
if os.path.isdir(folder_path):
# Replace only the first hyphen
new_folder_name = folder_name.replace(" - ", " = ", 1)
new_folder_path = os.path.join(music_folder, new_folder_name)
# Only rename if the new_folder_name differs
if folder_name != new_folder_name:
try:
os.rename(folder_path, new_folder_path)
print(f"Renamed: '{folder_name}' -> '{new_folder_name}'")
except Exception as e:
print(f"Failed to rename '{folder_name}': {e}")
os.listdir
fetches all folders in C:\MUSIC2025.folder_name.replace(" - ", " = ", 1)
replaces the first instance of [ICODE]" - "
[/ICODE] with [ICODE]" = "
[/ICODE].os.rename
renames the folder to its new name.if folder_name != new_folder_name
) to avoid pointless operations..py
file (e.g., rename_folders.py
).python rename_folders.py
rename_folders.bat
.@echo off
setlocal enabledelayedexpansion
:: Target folder
set "music_folder=C:\MUSIC2025"
cd /d "%music_folder%"
:: Loop through directories
for /d %%F in (*) do (
set "folder_name=%%F"
call set "new_folder_name=%%F"
set "new_folder_name=!new_folder_name: - = = !"
if not "!folder_name!"=="!new_folder_name!" (
ren "!folder_name!" "!new_folder_name!"
echo Renamed: "!folder_name!" -> "!new_folder_name!"
)
)
%music_folder%
is the target folder. Update it as required.for /d %%F in (*)
loops through folders only.set "new_folder_name=!new_folder_name: - = = !"
replaces [ICODE]" - "
[/ICODE] with [ICODE]" = "
[/ICODE] in folder names.ren
is the rename command to apply the new name.rename_folders.bat
.