I want to ask is it possible to make a rules for file managing program. For instance, if i want to move certain file in Image folder to move only .png and .img files. How i should declare rule in the configuration file that program would understand? If you would need I would my code gladly upload it. Which libraries i would need to use or give certain examples? Thank you in advance!
from tkinter import *
from tkinter import filedialog
import easygui
import shutil
import os
from tkinter import filedialog
from tkinter import messagebox as mb
from pathlib import Path
import logging
from datetime import date
import configparser
import configdot
def open_window():
read=easygui.fileopenbox()
return read
#logging config
if Path('app.log').is_file():
print ("Log file already exist")
else:
logging.basicConfig(filename='app.log', filemode="w", format='%(name)s - %(levelname)s - %(message)s ')
print ("Log file doesn't exist, so new one was created")
LOG_for="%(asctime)s, %(message)s"
logger=logging.getLogger()
logger.setLevel(logging.DEBUG)
# move file function
def move_file():
filename = filedialog.askopenfilename(initialdir = config.select.dir,
title = config.select.ttl,
filetypes = config.select.ft)
destination =filedialog.askdirectory()
dest = os.path.join(destination,filename)
if(source==dest):
mb.showinfo('confirmation', "Source and destination are the same, therefore file will be moved to Home catalog")
newdestination = Path("/home/adminas")
shutil.move(source, newdestination)
logging.shutdown()
logging.basicConfig(filename='app.log', filemode="a", format=LOG_for)
logging.info('File *' + filename + '* was moved to new destination: ' + newdestination)
else:
shutil.move(source, destination)
mb.showinfo('confirmation', "File Moved !")
#current_time()
logging.basicConfig(filename='app.log', filemode="a", format=LOG_for)
logging.info('File *' + filename + '* was moved to new destination: ' + destination)
# Create the root window
window = Tk()