Mine værktøjer
Du er her: Forside Python program eksempler. finddubletter.py

finddubletter.py

Tilbage

Hent filen

Licens GPL

Finddubletter

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
"""Usage: finddubletter [-p <path>] [-s <suffix>]
    finder filer i path med suffix sammenligner navne og fil 
    hvis der er sammenfald udskrives dette på stdout
"""
import findfiler



if __name__ == "__main__":

    import optparse
    import sys
    import os
    suffix = []
    P = optparse.OptionParser(usage=__doc__ % vars())

    P.add_option("-p","--path",
                 help="path to where the search begins",
                 action="store",
                 default="." )

    P.add_option("-s","--suffix",
                 help="files ending with suffix",
                 action="append",
                 default=suffix)

    P.add_option("-t","--test",
                 help="start pdb, hackers choice",
                 action="store_true",
                 default=False)

    P.add_option("-d","--dirs",
                 help="ignore dirs",
                 action="store_true",
                 default=[])

    (optlist, args) = P.parse_args(sys.argv[1:])


    PicDict = {}

    for file in findfiler.find(Path=optlist.path, onlySuffix=optlist.suffix, IgnoreDirs=optlist.dirs):
        name = os.path.basename(file)
        Data = { "filename":file, "name":name, "size":os.stat(file).st_size }
        try:
            PicDict[name].append(Data)
        except:
            PicDict[name] = [Data]

    for key, values in PicDict.items():
        if len(values) > 1:
            for i in range(len(values)-1):
                if values[i]["size"] == values[i+1]["size"]:
                    print key, values[i]["size"], values[i]["filename"], values[i+1]["filename"]


« august 2018 »
søn man tir ons tor fre lør
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Chat Rooms
Dyrk motion

Trim ballerup

 

Powered by Plone, the Open Source Content Management System