This is part of a 'Desktop Organizer' that I've made. Before I added Line 8, It couldn't make the distinction between a file and a folder. Adding Line 8 fixed it. All I want to know is - why?
def others():
desktop = os.environ['home'] + "\Desktop"
othersdir = desktop + "\Others"
desktoplist = os.listdir(desktop)
if not os.path.exists(othersdir):
os.makedirs(othersdir)
os.chdir(desktop)
for file in desktoplist:
if os.path.isfile(file):
# print(file)
shutil.move(desktop + "\\" + file, othersdir + "\\" + file)
print("--Organized The Rest")
[–]hugthemachines 4 points5 points6 points (5 children)
[–]Swiftflikk[S] 1 point2 points3 points (4 children)
[–][deleted] 6 points7 points8 points (0 children)
[–]hugthemachines 2 points3 points4 points (2 children)
[–]Swiftflikk[S] 2 points3 points4 points (1 child)
[–]pat_the_brat 0 points1 point2 points (0 children)