35 lines
785 B
Python
35 lines
785 B
Python
from tkinter.filedialog import askdirectory
|
|
from tkinter import Tk
|
|
from pathlib import Path
|
|
import os
|
|
|
|
# We don't want the GUI window of
|
|
# tkinter to be appearing on our screen
|
|
Tk().withdraw()
|
|
|
|
# Dialog box for selecting a folder.
|
|
file_path = askdirectory(title="Select your folder")
|
|
|
|
# Listing out all the files
|
|
# inside our root folder.
|
|
list_of_files = os.walk(file_path)
|
|
|
|
|
|
def moveFile(root, file):
|
|
if root != file_path:
|
|
old_file = Path(os.path.join(str(root), file))
|
|
new_file = Path(os.path.join(file_path, file))
|
|
print("Moving " + file)
|
|
os.rename(old_file, new_file)
|
|
|
|
|
|
def main():
|
|
for root, folders, files in list_of_files:
|
|
for file in files:
|
|
moveFile(root, file)
|
|
input()
|
|
|
|
|
|
main()
|
|
|