Exemple #1
0
        )
        print(*max(lol, key=lambda x: len(x))[1::], sep="\n")
        mstSp = max(lol, key=lambda x: sum([getsize(i) for i in x]))
        mxSp = sum([getsize(mstSp[i]) for i in range(len(mstSp))])
        print(
            f"\nThe most disk space ({mxSp}) could be recovered, by deleting copies of this file: \n{max(lol,key=lambda x : sum([getsize(i) for i in x]))[0]}"
        )
        print(f"Here are its {len(mstSp) - 1} copies")
        print(*max(lol, key=lambda x: sum([getsize(i) for i in x]))[1::],
              sep="\n")

    else:
        print("No duplicates found")


if __name__ == '__main__':
    path = join(".", "images")
    #the path to the image folder on my computer
    path = "C:\\Users\\Patri\\OneDrive\\Desktop\\Project1\\Project1\\images"
    # measure how long the search and reporting takes:
    t0 = time()
    report(search(all_files(path)))
    print(f"Runtime: {time() - t0:.2f} seconds")

    print("\n\n .. and now w/ a faster search implementation:")

    # measure how long the search and reporting takes:
    t0 = time()
    report(faster_search(all_files(path)))
    print(f"Runtime: {time() - t0:.2f} seconds")
Exemple #2
0
directory."""
    # Most Copies
    lol.sort(reverse=False)
    most_copies = max(lol, key=lambda x: len(x))

    print("== == Duplicate File Finder Report == ==")
    print(f"The File with the most duplicates is:\n {most_copies[0]}")
    print(f"Here are its {len(most_copies)-1} copies: ")
    for file in most_copies[1:]:
        print(file)

    # Most Space
    most_space = max(lol, key=lambda x: len(x) * getsize(x[0]))
    print(
        f"The file taking up the most disk space({(len(most_space) - 1) * getsize(most_space[0])}) is: "
        f"\n {most_space[0]}")
    print(f"Here are its {len(most_space) - 1} copies: ")
    for file in most_space[1:]:
        print(file)


if __name__ == '__main__':
    path = join(".", "images")
    t0 = time()
    report(search(all_files("/Users/cflock/Desktop/images")))
    print(f"Runtime: {time() - t0:.2f} seconds")
    print("\n\n .. and now w/ a faster search implementation:")
    t0 = time()
    report(faster_search(all_files("/Users/cflock/Desktop/images")))
    print(f"Runtime: {time() - t0:.2f} seconds")
Exemple #3
0
        ll = max(lol, key=len)
        ll.sort()
        print(f'The file with the most duplicates is: {ll[0]}')
        print(f'Here are its {len(ll)-1} copies:')
        for i in range(1, len(ll)):
            print(ll[i])
        ll = max(lol, key=lambda x: len(x) * getsize(x[0]))
        ll.sort()
        print(f'The most disk space {(len(ll)-1) * getsize(ll[0])} could be recovered, by deleting copies of this file: {ll[0]}')
        print(f'Here are its {len(ll) - 1} copies:')
        for i in range(1, len(ll)):
            print(ll[i])
    else:
        print("No duplicates found")


if __name__ == '__main__':
    path = join(".", "images")

    # measure how long the search and reporting takes:
    t0 = time()
    report(search(all_files(path))) # 1st step: calling all_files, 2nd step calling search
    print(f"Runtime: {time() - t0:.2f} seconds")

    print("\n\n .. and now w/ a faster search implementation:")

    # measure how long the search and reporting takes:
    t0 = time()
    report(faster_search(all_files(path)))
    print(f"Runtime: {time() - t0:.2f} seconds")
Exemple #4
0
    maximum = max(lol)
    i = []
    for e in lol:
        i.append(e)
    space = i  # I was stuck on this piece of the code for a decent amount of time, for the moment it will have to stay so i can get this in on time,
    print("== == Duplicate File Finder Report == ==")

    if len(lol) > 0:
        print(f"The file with the most duplicates is {maximum}")
        print(f"and the files that are taking up the most space are: {space}")
    else:
        print("No duplicates found")


if __name__ == '__main__':
    path = join(".", "images")

# measure how long the search and reporting takes:
# t0 = time()
# report(search(all_files(path)))
# print(f"Runtime: {time() - t0:.2f} seconds")
# #
# print("\n\n .. and now w/ a faster search implementation:")

# measure how long the search and reporting takes:
# t0 = time()
# report(faster_search(all_files(path)))
# print(f"Runtime: {time() - t0:.2f} seconds")

report(search(all_files(path)))