Please refer this script if you want to sort files in an folder according to their type.
NOTE :
Parameters to Edit:
dir_name = "C:\Python27" #Provide Your Folder Path
File_extension=r".py" #Provide Your File Extension
Please Run this Script as system user