Skip to content

Instantly share code, notes, and snippets.

@shivanandmn
Created December 5, 2020 02:37
Show Gist options
  • Save shivanandmn/bf0a410358d54ab712cf729c8f45e235 to your computer and use it in GitHub Desktop.
Save shivanandmn/bf0a410358d54ab712cf729c8f45e235 to your computer and use it in GitHub Desktop.
Changing the list of PDFs files from directory by using digit-only
# changing the names of the files in a directory
import os
import re
path = os.getcwd()
k = os.listdir(path)
for files in k:
x = re.search("\d+", files)
if x is None:
continue
os.rename(os.path.join(path, files),
os.path.join(path, f"{x.group()}--interview_QAs.pdf"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment