From 7a3ba625d3ee58b4d0bead4e74735108c6fe79bb Mon Sep 17 00:00:00 2001 From: schrom01 Date: Wed, 13 Apr 2022 16:48:17 +0200 Subject: [PATCH] added RenameFiles.py --- RenameFiles.py | 21 +++++++++++++++++++++ SelectedAdresses.py | 16 ---------------- 2 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 RenameFiles.py delete mode 100644 SelectedAdresses.py diff --git a/RenameFiles.py b/RenameFiles.py new file mode 100644 index 0000000..1fb1a41 --- /dev/null +++ b/RenameFiles.py @@ -0,0 +1,21 @@ +import os +import shutil +import tkinter +from tkinter import filedialog + +root = tkinter.Tk() +print("select List File:") +filename_Filelist = filedialog.askopenfilename() +print("select Directory:") +filename_Directory = filedialog.askdirectory() +root.withdraw +print(filename_Directory) +adress_file = open(filename_Filelist, "r", encoding='utf-8') +address_list = adress_file.read().splitlines() + +for adress in address_list: + filenames = adress.split(";") + try: + os.rename(filename_Directory + "/" + filenames[0], filename_Directory + "/" + filenames[1]) + except: + print("Failed Renaming File: " + filenames[0]) \ No newline at end of file diff --git a/SelectedAdresses.py b/SelectedAdresses.py deleted file mode 100644 index c33856f..0000000 --- a/SelectedAdresses.py +++ /dev/null @@ -1,16 +0,0 @@ -import os -import shutil -import tkinter -from tkinter import filedialog - -root = tkinter.Tk() -print("select File:") -filename_Filelist = filedialog.askopenfilename() -root.withdraw - -adress_file = open(filename_Filelist, "r") -address_list = adress_file.read().splitlines() - -for adress in address_list: - filenames = adress.split(";") - os.rename(filenames[0], filenames[1]) \ No newline at end of file