I know similar questions have been asked a few times on this site, but the solutions provided there did not work for me.
I need to rename files with titles such as
a.jpg
'b.jpg'
c.jpg
"d.jpg"
to
a.jpg
b.jpg
c.jpg
d.jpg
Some of these titles have quotation marks inside the title as well, but it doesn't matter whether they get removed or not.
I have tried
import os
import re
fnames = os.listdir('.')
for fname in fnames:
os.rename(fname, re.sub("\'", '', fname))
and
import os
for file in os.listdir("."):
os.rename(file, file.replace("\'", ""))
to then do the same for the " quotation mark as well, but the titles remained unchanged. I think it might be due to listdir returning the filenames with ' quotation marks around them, but I am not sure.
Edit: I am working on a Ubuntu 18.04.