def __init__(self, path=None, verbose=False): # Checking Condition for Default Argument if not path: path = "Downloads" # Setting Home Directory Path self.homedir = str(Path.home()) # Set the Source Directory Path [i.e the Downloads Path by DEFAULT] self.source = os.path.join(self.homedir, path) else: # Set the Source Directory Path [when Path isn't Downloads] self.source = os.path.join(path) # Copying All Files Names Present in the Source Directory self.all_files = [ files for files in listdir(self.source) if isfile(join(self.source, files)) ] ''' NOTE - We can change the "/Downloads" path to any other appropriate path if this script is required to run in that Directory. ''' # List Containing the files to be Moved self.documents = [] self.pictures = [] self.music = [] self.videos = [] self.archived = [] self.programming = [] self.others = [] # Including All Types of File Extensions Possible ## Calling 'fileExtensions' class file_ext = fileExtensions() ## Adding file extensions in required places to include that files in that directory self.picture_ext = file_ext.getExtension('Pictures') self.document_ext = file_ext.getExtension('Documents') self.music_ext = file_ext.getExtension('Music') self.video_ext = file_ext.getExtension('Videos') self.archived_ext = file_ext.getExtension('Archived') self.programming_ext = file_ext.getExtension('Programming') ## Adding CAPS Extensions too self.picture_ext += [i.upper() for i in self.picture_ext] self.document_ext += [i.upper() for i in self.picture_ext] self.music_ext += [i.upper() for i in self.music_ext] self.video_ext += [i.upper() for i in self.video_ext] self.archived_ext += [i.upper() for i in self.archived_ext] self.programming_ext += [i.upper() for i in self.programming_ext] # Flag if the User wants to Print the Output into the Console [Files that are been moved & its Status] self.flag = verbose # Dictionary to Keep Track of the Files Moved according to their Type self.historyDictionary = {} # Extracting Information about the Files Present self.extractingFiles()
def showExtensions(self, extension_type = None): if extension_type: return fileExtensions().getExtension(extension_type) else: return fileExtensions().getExtension()