Python Forum
Re writing poste to make sense please help me
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re writing poste to make sense please help me
#1
Hey guys I can get this to run on android but I can get it to run on Windows when I change the path can u guys help please. I do need and explanation so I can learn though
Cheers
Nathan
...........................
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')

Sorry it didnt come up as sorce i incased it wrong
Reply


Messages In This Thread
Trying to write a clean up program need help!! - by Nearrivers - Mar-31-2018, 05:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can anyone make sense of this? steve_shambles 7 3,255 Apr-19-2020, 11:22 AM
Last Post: steve_shambles
  These boolean statements don't make sense? Athenaeum 6 5,076 Oct-03-2017, 03:34 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020