Skip to content

Instantly share code, notes, and snippets.

@diegoquintanav
Last active March 25, 2020 09:25
Show Gist options
  • Save diegoquintanav/c76a5acc4d916587695fb639a20cb39a to your computer and use it in GitHub Desktop.
Save diegoquintanav/c76a5acc4d916587695fb639a20cb39a to your computer and use it in GitHub Desktop.
rename files using python
# basic renaming of files, to enforce a minimum consistency
from pathlib import Path
for ix, file in enumerate(sorted(Path.cwd().glob('*'))):
new_filename = f'{ix:02}_' + file.name.lower().replace(' ','_')
print(f'{file.name} > {new_filename}')
file.rename(new_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment