Last active
November 19, 2019 22:11
-
-
Save endolith/149676 to your computer and use it in GitHub Desktop.
Convert newlines in filenames to spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
# I often find myself opening a lot of PDFs, copying and pasting the title of | |
# the paper, and renaming the file. Often these names have newlines in them, | |
# though, so this script renames them with spaces instead of newlines. | |
for name in os.listdir(os.curdir): | |
if '\n' in name: | |
new_name = name.replace('\n', ' ') | |
print(repr(name), '->', repr(new_name)) | |
os.rename(name, new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment