I want to rename multiple files in a directory, if they start with "#", for example:
#222_message_split -> 222_message_split
#013_message_split2 -> 013_message_split2
edit: I tried this:
for filename in os.listdir(PATH):
if filename.startswith("#"):
os.rename(filename, filename[1:])
edit2: with the help of pstatix I got the code to work, now checking subdirectories for "#_____" files as well.
for root, dirs, files in os.walk(PATH):
for dir in dirs:
if dir.startswith("#"):
org_fp = os.path.join(root, dir)
new_fp = os.path.join(root, dir[1:])
os.rename(org_fp, new_fp)