Package: copy2hash
copy2hashCopy or rename any file(s) to ahash-securedfilename via terminalcopy2hashcopies or renames file(s) with regular titles to file(s) with ahash-securedtitle by using the terminal or inpython-framework. Having unique filenames is essential for the correct indexing of databases, especially if the data come from different pipelines. Also, it is important if the filename or/and directory containsmeta-information, which extend the length of the valid file lengths.Havingregular-filename pairs such asexample.input⇄example.outputcan brings very fast confusion and makes analysis of data very confusing. The secured hash algorithms (SHA) [1-5] incopy2hashprovides a safe way to generate distinguishable filenames like:example.input⇄example.output⟶7e2229daab26b247b877565505b6aaf131014f2cb64e4c4ca796fbe0dc2fadc4.input⇄4bd077ed771af9ad97e3f2dc45583a14af014ebafb73a846f2436a168ae3eafa.outputThe followingSHAalgorithms [1-5] are available:sha1sha224sha256sha384sha512blake2bblake2smd5sha3_224sha3_256sha3_384sha3_512shake_128with fixed32character lengthshake_256with fixed32character lengthand the copied or moved processed will be automatically logged as:*.csv-file:*.json-file*.pkl-file*.txt-file*.yaml-file*.xml-fileInstallationpip install copy2hashorpip install https://github.com/Anselmoo/copy2hash.gitorpipinstall-rrequirements.txt
pythonsetup.pyinstallRequirmentsPython3 >= 3.6dict2xml>=1.7.0PyYAML>=5.3.1Usage╰─copy2hash*-h
usage:copy2hash[-h][-r[REPORT[REPORT...]]][-rnREPORT_NAME][-s[SHA[SHA...]]][-dirDIRECTORY][-mv][-fxt][-sxt][-nfxt][-ver][-v][infile[infile...]]copyorrenameanyfile(s)toahash-securedfilenameviaterminal

positionalarguments:infilefile(s)tocopyortorenamewithregularfilenametosecuredhashfilename

optionalarguments:-h,--helpshowthishelpmessageandexit-r[REPORT[REPORT...]],--report[REPORT[REPORT...]]defineoneoraseriesoffileformat(s)fortherename-report(s)toretracethecopyingorrenameofthefile(s).Theavailabelfileformatsare:'csv','json','pkl','txt','yaml','xml',orownfile-extensionasASCII;defaultis'json'-rnREPORT_NAME,--report_nameREPORT_NAMEdefinethereportnameforthecopiedormovefile(s);defaultis'copy_report'-s[SHA[SHA...]],--sha[SHA[SHA...]]defineoneoraseriesofsecurehashalgorithms(sha)forcopyingorrenameofthefile(s).Theavailabelsecurehashalgorithms(sha)are:'sha1','sha224','sha256','sha384','sha512','blake2b','blake2s','md5','sha3_224','sha3_256','sha3_384','sha3_512','shake_128','shake_256';default'sha256'.The'shake_128'and'shake_256'aredefinedfor32characterlength.-dirDIRECTORY,--directoryDIRECTORYreplacethestandarddirectory('./')byaspecificdirectory('./path').Ifthespecificdirectorynotexist,thedirectorywillbecreated.Thiscanrequiredsudorights.-mv,--movemovingthefile(s)insteadofcopyingthefileswithregularfilenametosecurehashfilename-fxt,--file_extensionreplacedthegivenfile-extensionbytheabbreviationsoftheusedsecurehashalgorithms(sha)-sxt,--file_suffixremovedthegivenfile-extensionandaddasuffixinfrontofthefilebasedontheabbreviationsoftheusedsecurehashalgorithms(sha).Itisseperatedbycolonlike'sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'-nfxt,--no_file_extensionremovedtheanyfile-extensionandjustcopyormovethefile(s)assharenamedfile(s)-ver,--verboseenabletheverbosemode-v,--versiondisplaysthecurrentversionofcop2hashOther ExamplesFor keeping the regular file-extension, use:copy2hash * -r json csv yamlregular-filenamesha256-filenameexample.out→c8e1f67ad67b8f456afe76b5eb5d6dd0a919b1537cd67b9419f86158e4d9c1b4.outexample.t→97c7bc3705df72f76cf3d3d55228751bc6895a488fb004b112914d4a05447c16.texample.tx→11297eae82d7866c4dd42e79b8082a5256fa3d54e7e1bf60ab87747e9b664303.txexample.txt→e7cb632359a2be17c1008b50f9ec85691cd5d66834d5fe8f63ef65ceb06682ee.txtexample_1.txt→85a6fae2fca1342a85222088ff0342cbea8222e4140aba96690691c9d58e5786.txtexample_2.txt→0329cb55ddfab933d9753686ddb193148003611df672a4a41aad014ead4767f9.txtexample_l.txt→eb4d990362cbf5cccd0b49374b71ca3f799c7262352c9fda7ba875ba034f7168.txtRemoving the regular file-extension and adding the SHA-key in front, use:copy2hash * -r json csv yaml -sxtregular-filenamesha256-filenameexample.out→sha256-c8e1f67ad67b8f456afe76b5eb5d6dd0a919b1537cd67b9419f86158e4d9c1b4example.t→sha256-97c7bc3705df72f76cf3d3d55228751bc6895a488fb004b112914d4a05447c16example.tx→sha256-11297eae82d7866c4dd42e79b8082a5256fa3d54e7e1bf60ab87747e9b664303example.txt→sha256-e7cb632359a2be17c1008b50f9ec85691cd5d66834d5fe8f63ef65ceb06682eeexample_1.txt→sha256-85a6fae2fca1342a85222088ff0342cbea8222e4140aba96690691c9d58e5786example_2.txt→sha256-0329cb55ddfab933d9753686ddb193148003611df672a4a41aad014ead4767f9example_l.txt→sha256-eb4d990362cbf5cccd0b49374b71ca3f799c7262352c9fda7ba875ba034f7168More ExamplesGenerate a report in thejson- andyaml-format:copy2hash example.input example.output -r json yaml{"index":[0,1],"filename":["example.input","example.output"],"mode":["copy","copy"],"home_dir":[".","."],"copy_dir":[".","."],"sha256":["7e2229daab26b247b877565505b6aaf131014f2cb64e4c4ca796fbe0dc2fadc4.input","4bd077ed771af9ad97e3f2dc45583a14af014ebafb73a846f2436a168ae3eafa.output"]}copy_dir:-.-.filename:-example.input-example.outputhome_dir:-.-.index:-0-1mode:-copy-copysha256:-7e2229daab26b247b877565505b6aaf131014f2cb64e4c4ca796fbe0dc2fadc4.input-4bd077ed771af9ad97e3f2dc45583a14af014ebafb73a846f2436a168ae3eafa.outputUsing as Built-infromcopy2hashimportcopy2hashfrompathlibimportPathargs={"infile":list(Path("test").glob("example1.txt")),"report":["json"],"report_name":"copy_report","sha":["sha256"],"directory":None,"move":None,"file_extension":False,"file_suffix":False,"no_file_extension":False,"verbose":True,"version":False,}copy2hash.command_line_runner(opt=args)AuthorAnselm HahnContributionsI'm happy to accept how to improve batchplot; please forward yourissuesorpull requests.Keep in mind thatpull requestshave to pass TravisCI in combination withflake8,black, andpydocstyle.LicenseThe source code ofcopy2hashis licensed under theMIT license.Referenceshttps://docs.python.org/3/library/hashlib.htmlhttps://tools.ietf.org/html/rfc1321.htmlhttps://en.wikipedia.org/wiki/NIST_hash_function_competitionhttps://131002.net/blake/https://docs.python.org/3/library/hashlib.html#hashlib.blake2CHANGES{changes}
TODO{todo}