Хорошо, я исправил свой код. Вам нужно сделать две вещи. Во-первых, у вас должен быть "directory_of_Files", который содержит все файлы и подпапки с файлами. Затем у вас должна быть новая родительская папка, new_parent_directory, которая пуста. new_parent_directory будет организован по окончанию файлов из файлов в "directory_of_Files".  По сути, этот сценарий ищет все файлы в каталоге и каталогах в этом каталоге, затем создает список окончаний файлов, а затем создает каталоги в новом каталоге на основе этих окончаний файлов, а затем принимает все файлы в родительском каталоге и перемещает их во вновь созданные каталоги. 
Если у вас установлен Python .....
В терминале введите 
python
затем, 
import os
затем, 
#this is ths directory that contains all your files 
#YOU MUST CHANGE THIS!!!!!!
directory_of_Files = "/Users/name/Desktop/test1"
#AND YOU MUST CHANGE THIS!!!!!!
new_parent_directory = "/Users/name/Desktop/newhometest"
#From here down, it's all magic. 
all_subfolders = [x[0] for x in os.walk(directory_of_Files)]
#Get the full file name and only the files
filenames=[]
for subfolder in all_subfolders:
    os.chdir(subfolder)
    for file in filter(os.path.isfile, os.listdir(os.getcwd())):
        if not file.startswith("."):
            filenames.append(os.getcwd()+"/"+file)
#get the file endings
all_files_endings = []
for i in filenames:
    all_files_endings.append(i.split(".",1)[1])
#remove the duplications
all_files_endings = list(set(all_files_endings))
#create some folders in the new_directory with the file endings
for fileExtensions in all_files_endings:
    os.mkdir(new_parent_directory + "/" + fileExtensions)    
#move the files from their old destination to their new destination 
newnames=[]
for subfolder in all_subfolders:
    os.chdir(subfolder)
    for file in filter(os.path.isfile, os.listdir(os.getcwd())):
        if not file.startswith("."):
            newnames.append(new_parent_directory+"/"+file.split(".",1)[1]+"/"+file)
            print file 
if len(filenames) == len(newnames):
    for i in range(len(filenames)):
        shutil.move(filenames[i], newnames[i])
Я проверял это на Mac OSX 10.11 с python 2.7. Вы также можете просто скопировать весь код в текстовый файл, сохранить его как «нечто.py», а затем запустить его из терминала с кодом, 
python something.py