Skip to content

Instantly share code, notes, and snippets.

@nnnolan
Last active March 1, 2023 14:46
Show Gist options
  • Save nnnolan/4c9a44062ceff9bca0eaf0e827752abf to your computer and use it in GitHub Desktop.
Save nnnolan/4c9a44062ceff9bca0eaf0e827752abf to your computer and use it in GitHub Desktop.
#quick fix for export pdf's still having the extension, we don't want that
directory = os.fsencode(os.path.join("exports"))
for file in os.listdir(directory):
filename = os.fsdecode(file)
if filename.endswith(".pdf"): #filename.pdf
os.rename(os.path.join("exports", filename), os.path.join("exports", filename.split(".")[0]))
if filename.endswith(")"): #filename.pdf(1)
temp = filename.split(".")[0] + '_' + filename[-3:]
os.rename(os.path.join("exports", filename), os.path.join("exports", temp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment