From 59a0bbd4b81313eba362e9b42f0a1be788b027b8 Mon Sep 17 00:00:00 2001 From: Cristina Cochior Date: Fri, 20 Dec 2019 18:19:22 +0100 Subject: [PATCH] added code to rename the files --- renaming.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 renaming.py diff --git a/renaming.py b/renaming.py new file mode 100644 index 0000000..7b7bcd8 --- /dev/null +++ b/renaming.py @@ -0,0 +1,19 @@ +import sys, os +import re + +folder_path = "static/files/" +olds = "'" +new = "" + +def replace(folder_path, old, new): + for path, subdirs, files in os.walk(folder_path): + for name in files: + for old in olds: + if(old.lower() in name.lower()): + file_path = os.path.join(path,name) + name = name.lower().replace(old,new) + new_name = os.path.join(path,name) + print(new_name) + os.rename(file_path, new_name) + +replace(folder_path, olds, new)