0

I want to compare multiple files of one directory with multiple files in another directory by their byte size in order to find the closest "match".
This is my code so far:

import os
# these are lists of all the filenames in respective directories
firstDir = os.listdir('first')
secondDir = os.listdir('second')
# I imagine using this for loop to compare the byte values, but I have no idea which method to use
for item in firstDir
    # ...
4

1 回答 1

1

这将使您开始,其余的您应该能够弄清楚。

import os
p='yourdir'
firstDir = os.listdir(p)
for item in firstDir:
    print os.path.getsize(p+"/"+item)
于 2014-05-17T21:18:28.220 回答