feat: rename folders
39
script.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Cesta ke složce, kde jsou projekty
|
||||||
|
projects_folder = './src/projects'
|
||||||
|
|
||||||
|
# Počítadla
|
||||||
|
total_folders = 0
|
||||||
|
renamed_folders = 0
|
||||||
|
skipped_folders = 0
|
||||||
|
|
||||||
|
# Projde všechny složky v složce projects
|
||||||
|
for root, dirs, files in os.walk(projects_folder):
|
||||||
|
for dir_name in dirs:
|
||||||
|
total_folders += 1 # Započítáme každou složku
|
||||||
|
|
||||||
|
# Získáme původní cestu ke složce
|
||||||
|
original_path = os.path.join(root, dir_name)
|
||||||
|
|
||||||
|
# Převést název složky na lowercase a nahradit mezery a podtržítka pomlčkami
|
||||||
|
new_dir_name = dir_name.lower().replace(' ', '-').replace('_', '-')
|
||||||
|
new_path = os.path.join(root, new_dir_name)
|
||||||
|
|
||||||
|
# Pokud je původní název jiný než nový (abychom předešli zbytečným přejmenováním)
|
||||||
|
if original_path != new_path:
|
||||||
|
try:
|
||||||
|
os.rename(original_path, new_path)
|
||||||
|
print(f"Přejmenovávám složku: '{original_path}' -> '{new_path}'")
|
||||||
|
renamed_folders += 1
|
||||||
|
except OSError as e:
|
||||||
|
print(f"Chyba při přejmenování složky {original_path}: {e}")
|
||||||
|
else:
|
||||||
|
print(f"Složka '{original_path}' již má správný název, preskakuji.")
|
||||||
|
skipped_folders += 1
|
||||||
|
|
||||||
|
# Výsledný souhrn
|
||||||
|
print("\n--- SOUHRN ---")
|
||||||
|
print(f"Celkový počet složek: {total_folders}")
|
||||||
|
print(f"Počet přejmenovaných složek: {renamed_folders}")
|
||||||
|
print(f"Počet přeskočených složek (již správné): {skipped_folders}")
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 353 KiB After Width: | Height: | Size: 353 KiB |
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 156 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |