Package: twintrimmer
IntroductionTwintrimmer is a project designed to automatically remove duplicate files
specially those created by downloading in a browser.Build StatusBuild:ModivationRelatively often I find that I download a file multiple times using Chrome
or Firefox and they rather than over writing the file “<filename>.<ext>”
will name the newest copy “<filename>(#).<ext>” I built this tool to
automatically remove duplicate versions by comparing the names and then
validating the content with a checksum.Usageusage: twintrim [-h] [-n] [-r] [–verbosity VERBOSITY][–log-file LOG_FILE] [–log-level LOG_LEVEL]
[-p PATTERN] [-c] [-i]
[–hash-function {‘sha224’, ‘sha384’, ‘sha1’, ‘md5’, ‘sha512’, ‘sha256’}
[–make-links] [–remove-links]
pathtool for removing duplicate filespositional arguments:path                  path to checkoptional arguments:-h,--helpshow this help message and exit-n,--no-actionshow what files would have been deleted-r,--recursivesearch directories recursively--verbosityVERBOSITYset print debug level--log-fileLOG_FILEwrite to log file.--log-levelLOG_LEVELset log file debug level-pPATTERN,--patternPATTERNset filename matching regex-c,--only-checksumtoggle searching by checksum rather than name first-i,--interactiveask for file deletion interactively--hash-function{‘sha224’, ‘sha384’, ‘sha1’, ‘md5’, ‘sha512’, ‘sha256’}
set hash function to use for checksums--make-linkcreate hard link rather than remove file--remove-linksremove hardlinks rather than skipping--versionshow program’s version number and exitExamplesfind matches with default regex:$ twintrim -n ~/downloadsfind matches ignoring the extension:$  ls examples/
Google.html  Google.html~
$ twintrim -n -p '(^.+?)(?: \(\d\))*\..+' examples/
examples/Google.html~ would have been deletedfind matches with “__1” added to basename:$ ls examples/underscore/
file__1.txt  file.txt
$ twintrim -n -p '(.+?)(?:__\d)*\..*' examples/underscore/
examples/underscore/file__1.txt to be deletedTry it outIf you would like to try it out I have included an example directory. After
cloning the repository, try running:python -m twintrimmer examples/Running the TestsUnit testsTo run tests:python -m unittest discover -p '*_test.py'or using nose:python3 -m nose --with-json-extendednote:pyfakefs is not being updated on pypi and should be installed directly
from the github repository, due to issues with pyfakefs and python3 in
the pypi versioncommand to install pyfakefs:pip install git+https://github.com/jmcgeheeiv/pyfakefsCode coverageTo show the test coverage:python -m nose --with-coverage --cover-package twintrimmer.twintrimmerBehavior testsTo run tests:behaveMaking the DocumentationHTML docscd docs/
make htmlDocumentation Coverage ReportTo make the coverage report appear in the docs:cd docs/
make coverage
make htmlOptionally, you can view the coverage report directly after
runningmake coverage:cat _build/coverage/python.txtMiscellaneousHash algorithm optionsDepending on your installed OpenSSL library your available algorithms might change.The following are the hash algorithms guaranteed to be supported by this
module on all platforms.sha224sha384sha1md5sha512sha256Additionally, these algorithms might be available (potentially more)ecdsa-with-SHA1whirlpooldsaWithSHAripemd160md4For more information on these algorithms please see the hashlib documentation:https://docs.python.org/3/library/hashlib.html