@@ -0,0 +1,2425 @@
+#!C:/Python34/python.exe%0A# -*- coding: utf-8 -*-%0A%0Aimport os%0Aimport sys%0Aimport shutil%0Aimport argparse%0Afrom datetime import date%0A%0A%0Adef parse_arguments():%0A    parser = argparse.ArgumentParser(description='Sort files')%0A    parser.add_argument('-s', '--source', required=True, help='Source folder')%0A    parser.add_argument('-d', '--destination', required=True, help='Destination folder')%0A    parser.add_argument('-t', '--type', required=True, choices=%5B'ext', 'year', 'month', 'day'%5D,%0A                        help='Sort type')%0A    args = parser.parse_args()%0A%0A    return args.source, args.destination, args.type%0A%0A%0Adef get_dest_folder(sourceFolder, file, destFolder, sortType):%0A    if sortType == %22ext%22:%0A        (filename, ext) = os.path.splitext(file)%0A        destFolder = os.path.join(destFolder, ext)%0A    else:%0A        sourceFile = os.path.join(sourceFolder, file)%0A        fileModifDate = date.fromtimestamp(os.path.getmtime(sourceFile))%0A        fmYear = fileModifDate.strftime(%22%25Y%22)%0A        fmMonth = fileModifDate.strftime(%22%25m%22)%0A        fmDay = fileModifDate.strftime(%22%25d%22)%0A        if sortType == %22year%22:%0A            destFolder = os.path.join(destFolder, fmYear)%0A        elif sortType == %22month%22:%0A            destFolder = os.path.join(destFolder, fmYear + '-' + fmMonth)%0A        elif sortType == %22day%22:%0A            destFolder = os.path.join(destFolder, fmYear + '-' + fmMonth + '-' + fmDay)%0A%0A    return destFolder%0A%0A%0Adef get_dest_file(file, destFolder):%0A    (filename, ext) = os.path.splitext(file)%0A    destFile = os.path.join(destFolder, file)%0A    numFile = 0%0A    while os.path.exists(destFile):%0A        numFile += 1%0A        newfile = %22%7B0%7D_%7B1%7D%7B2%7D%22.format(filename, numFile, ext)%0A        destFile = os.path.join(destFolder, newfile)%0A    return destFile%0A%0A%0Adef main():%0A    (sourceFolder, destinationFolder, sortType) = parse_arguments()%0A    if not os.path.exists(sourceFolder):%0A        sys.exit('Missing folder: %25s', sourceFolder)%0A    for root, dirs, files in os.walk(sourceFolder):%0A        for file in files:%0A            sourceFile = os.path.join(root, file)%0A            destFolder = get_dest_folder(root, file, destinationFolder, sortType)%0A            if not os.path.exists(destFolder):%0A                os.makedirs(destFolder)%0A            destFile = get_dest_file(file, destFolder)%0A            print(%22%7B0%7D -%3E %7B1%7D%22.format(sourceFile, destFile))%0A            shutil.move(sourceFile, destFile)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Create sort_folder.py