예제 #1
0
def createFolders():
    """
        This is the function that creates a new folder named as 
        PowFu- files organizer if the script was never ran in the context folder.

        If the script has already ran into this folder or there are no files except "the program",
        it will inform the user that there are no files to organize.

        Parametres : This function does not receive any parametre
        Return : This function returns a integer value "flag", which I used to show the final result.
        To be more specific, if flag is 0 that means that a folder where created and some files were organized otherwise do nothing.

    """
    flag = 0
    total = 0
    current_path = os.getcwd()
    extensions_found = []
    if current_path not in folder_exceptions:
        for i in os.listdir(current_path):
            if os.path.isfile(i):
                if exts.guess(i) not in extensions_found:
                    extensions_found.append(exts.guess(i))
                total += 1
        if total > 0:
            if not os.path.exists(main_folder):
                os.makedirs(main_folder)
            os.chdir(os.path.join(current_path, main_folder))
            createOnce(extensions_found)
        else:
            flag = 1
            print("No files to organize!")
    else:
        flag = 1
        print("Access denied - You can not organize this folder!")
    return flag
예제 #2
0
def main():

    total_documents = 0
    total_music = 0
    total_videos = 0
    total_images = 0
    total_compacted = 0
    total_exe = 0
    total_others = 0
    total_files = 0

    showTop()
    for file in os.listdir(os.getcwd()):
        if os.path.isdir(file):
            pass
        if os.path.isfile(file):
            extension = exts.guess(file)
            if file.endswith(extension):
                if exts.isMusic(extension):
                    moveFiles(file, folders_name[0])
                    total_music = total_music + 1
                elif exts.isImage(extension):
                    moveFiles(file, folders_name[1])
                    total_images = total_images + 1
                elif exts.isVideo(extension):
                    moveFiles(file, folders_name[2])
                    total_videos = total_videos + 1
                elif exts.isDoc(extension):
                    moveFiles(file, folders_name[3])
                    total_documents = total_documents + 1
                elif exts.isCompacted(extension):
                    moveFiles(file, folders_name[4])
                    total_compacted = total_compacted + 1
                elif exts.isExecutable(extension):
                    if file == "PowFu-File Organizer.run":
                        pass
                    else:
                        moveFiles(file, folders_name[5])
                        total_exe = total_exe + 1
                else:
                    moveFiles(file, folders_name[6])
                    total_others = total_others + 1
    total_files = total_compacted + total_documents + total_exe + total_images + total_videos + total_others

    if flag == 0:
        print("Total Number of file copied: %s" % total_files)
        print("Total Number of Documents copied: %s" % total_documents)
        print("Total Number of Musics copied: %s" % total_music)
        print("Total Number of Images copied: %s" % total_images)
        print("Total Number of Videos copied: %s" % total_videos)
        print("Total Number of Compacteds copied: %s" % total_compacted)
        print("Total Number of Programs copied: %s" % total_exe)
        print("Total Number of others file copied: %s" % total_others)
        print(
            "Your Computer is organized now! Go to %s" %
            os.path.join(os.getcwd()), main_folder)

        time.sleep(3)