Mar-31-2018, 07:10 PM
I am writing a program to use on not android and windows in order to reorganize files into folders by there extension and delete empty folders.
At the moment it runs for android and works great but does not work for windows.
I'm fairly new to python and would very much like an explanation as to why it doesn't work and how I can change it.
Thank you for reading this so far.
Here is my code so far
At the moment it runs for android and works great but does not work for windows.
I'm fairly new to python and would very much like an explanation as to why it doesn't work and how I can change it.
Thank you for reading this so far.
Here is my code so far
import os import shutil #change the pathway were to sort path ="/internalsharedstorage/downloads/" name = os.listdir(path) folder_name = ['image','text','exe','mp3','mp4','apk','pdf','zip','rar','sav'] for x in range(0,10): if not os.path.exists(path+folder_name[x]): os.makedirs(path+folder_name[x]) # movement of files for files in name: if '.pdf' in files and not os.path.exists(path+'pdf/'+files): shutil.move(path+files, path+'pdf/'+files) elif '.zip' in files and not os.path.exists(path+'zip/'+files): shutil.move(path+files, path+'zip/'+files) elif '.exe' in files and not os.path.exists(path+'exe/'+files): shutil.move(path+files, path+'exe/'+files) elif '.jpeg' in files and not os.path.exists(path+'image/'+files): shutil.move(path+files, path+'image/'+files) elif '.txt' in files and not os.path.exists(path+'text/'+files): shutil.move(path+files, path+'text/'+files) elif '.mp3' in files and not os.path.exists(path+'music/'+files): shutil.move(path+files, path+'music/'+files) elif '.sav' in files and not os.path.exists(path+'save/'+files): shutil.move(path+files, path+'sav/'+files) elif '.rar' in files and not os.path.exists(path+'rar/'+files): shutil.move(path+files, path+'rar/'+files) elif '.mp4' in files and not os.path.exists(path+'mp4/'+files): shutil.move(path+files, path+'mp4/'+files) elif '.apk' in files and not os.path.exists(path+'apk/'+files): shutil.move(path+files, path+'apk/'+files) else: print ('cant be moved')Cheers guys