Skip to content

Instantly share code, notes, and snippets.

@profrodai
Created August 3, 2020 23:03
Show Gist options
  • Select an option

  • Save profrodai/ecb45c9d4cab6f58e66106b2eed59079 to your computer and use it in GitHub Desktop.

Select an option

Save profrodai/ecb45c9d4cab6f58e66106b2eed59079 to your computer and use it in GitHub Desktop.
from pathlib import Path
import os
p = Path('03_Books/')
for ix, path in enumerate(sorted(os.listdir(p))):
if '.DS_Store' not in path:
full_path = os.path.join(p, path)
if os.path.isdir(full_path):
if ix < 10:
ix = f'0{ix}'
new_path = os.path.join(p, f'0{ix}_{path}')
os.rename(full_path, new_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment