I am very new to Python, but I thought it would be interesting to make a program to sort all my downloads, but I have a little problem with it. It works great if my addressee has only one word, but if the addressee has two or more words, this happens incorrectly and the program gets stuck in a loop. Does anyone have an idea to compare lists than me.
>>>for i in dstdir:
>>> print i.split()
['CALIFORNICATION']
['THAT', "'70S", 'SHOW']
['THE', 'BIG', 'BANG', 'THEORY']
['THE', 'OFFICE']
['DEXTER']
['SPAWN']
['SCRUBS']
['BETTER', 'OF', 'TED']
>>>for i in dstdir:
>>> print i.split()
['Brooklyn.Nine-Nine.S01E16.REAL.HDTV.x264-EXCELLENCE.mp4']
['Revolution', '2012', 'S02E12', 'HDTV', 'x264-LOL[ettv]']]
['Inequality', 'for', 'All', '(2013)', '[1080p]']
This is an example of listing output.
I have a destination directory with only folders in it and a download directory. I want the program to automatically look up the name of the source file, and then look at the name of the recipient. if the recipient name is in the source name, then I have yes to continue and copy the downloaded file so that it is sorted in my collection.
destination = '/media/mediacenter/SAMSUNG/SERIES/'
source = '/home/mediacenter/Downloads/'
dstdir = os.listdir(destination)
srcdir = os.listdir(source)
for i in srcdir:
source = list(i.split())
for j in dstdir:
count = 0
succes = 0
destination = list(j.split())
if len(destination) == 1:
while (count < len(source)):
if destination[0].upper() == source[count].upper():
print 'succes ', destination, ' ', source
count = count + 1
elif len(destination) == 2:
while(count < len(source)):
if (destination[0].upper() == source[count].upper()):
succes = succes + 1
count = len(source)
count = 0
while(count < len(source)):
if (destination[1].upper() == source[count].upper()):
succes = succes + 1
count = len(source)
count = 0
if succes == 2:
print 'succes ', destination, ' ', source
"" ; , , .