So you have lots of files scattered in directory and you are finding it very difficult to organize. Well my below script will prompt file name of each, and will ask move the file to predefined location. If 3 or invalid selection, files will not move.
Works only on windows.
==========================================
import os
data1 = [f for f in os.listdir('.') if os.path.isfile(f)]
loc1 = "G:\\BooksLibrary"
loc2 = "G:\\Waste"
for x in data1:
print "Where do you want to move " + x
sel1 = raw_input("Press 1 for Book, 2 for waste, 3 for nowhere ")
if sel1 =="1":
cmd1 = "move \"" + x + "\" " + loc1
print cmd1
os.system(cmd1)
elif sel1 =="2":
cmd2 = "move \"" + x + " " +loc2
print cmd2
os.system(cmd2)
elif sel1 =="3":
print x + " is not moved"
else:
print "Invalid selection, file not moved"
Works only on windows.
==========================================
import os
data1 = [f for f in os.listdir('.') if os.path.isfile(f)]
loc1 = "G:\\BooksLibrary"
loc2 = "G:\\Waste"
for x in data1:
print "Where do you want to move " + x
sel1 = raw_input("Press 1 for Book, 2 for waste, 3 for nowhere ")
if sel1 =="1":
cmd1 = "move \"" + x + "\" " + loc1
print cmd1
os.system(cmd1)
elif sel1 =="2":
cmd2 = "move \"" + x + " " +loc2
print cmd2
os.system(cmd2)
elif sel1 =="3":
print x + " is not moved"
else:
print "Invalid selection, file not moved"
Comments
Post a Comment