{"id":907,"date":"2021-05-05T14:52:29","date_gmt":"2021-05-05T21:52:29","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=907"},"modified":"2021-05-05T14:52:29","modified_gmt":"2021-05-05T21:52:29","slug":"164-batch-script-to-create-md5-hash-for-every-file-in-the-folder-then-write-them-to-the-text-file","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2021\/05\/164-batch-script-to-create-md5-hash-for-every-file-in-the-folder-then-write-them-to-the-text-file\/","title":{"rendered":"#164 Batch script to create md5 hash for every file in the folder, then write them to the text file"},"content":{"rendered":"<p>#164 Batch script to create md5 hash for every file in the folder, then write them in text file<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n@echo off\r\n\r\nFOR \/F &quot;delims=&quot; %%F IN ('dir \/B \/A \/S *') DO (\r\n  for %%D in (&quot;%%~dpF\\.&quot;) do (\r\n  set filename=%%~nxD.md5\r\n  )\r\n)\r\n\r\nTYPE NUL &gt; %filename%\r\n\r\nFor \/R . %%f in (*.rar) Do (\r\n    for \/F &quot;delims=&quot; %%a in ('&quot;certutil -hashfile &quot;%%f&quot; MD5 | findstr \/V &quot;:&quot;&quot;') do (\r\n      set \/p &quot;=%%a &quot; &lt;nul &gt;&gt; %filename%\r\n      echo *%%~nxf&gt;&gt; %filename%\r\n    )  \r\n)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#164 Batch script to create md5 hash for every file in the folder, then write them in text file @echo off FOR \/F &quot;delims=&quot; %%F IN (&#8216;dir \/B \/A \/S *&#8217;) DO ( for %%D in (&quot;%%~dpF\\.&quot;) do ( set filename=%%~nxD.md5 ) ) TYPE NUL &gt; %filename% For \/R . %%f in (*.rar) Do ( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-907","post","type-post","status-publish","format-standard","hentry","category-batch"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-eD","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":432,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/07\/windows-batch-script-to-print-nth-lines-after-line-containing-matched-string\/","url_meta":{"origin":907,"position":0},"title":"#63 Batch script to print n-th lines after line containing matched string","author":"gantovnik","date":"2019-07-26","format":false,"excerpt":"[code language=\"python\"] @echo off setlocal enableDelayedExpansion set \"word=VON MISES\" set \"keep=3\" set \"file=model.f06\" find \" X \" model.f06 > extract_weight.txt del extract_stress.txt set n=%keep% for \/f \"usebackq delims=\" %%A in (\"%file%\") do ( set \"ln=%%A\" if \"!ln:%word%=!\" neq \"!ln!\" ( echo( set n=0 ) if !n! lss !keep! ( echo\u2026","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1969,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/09\/393-count-the-number-of-files-with-a-specific-extension-in-a-folder-using-batch-script\/","url_meta":{"origin":907,"position":1},"title":"#393 Count the number of files with a specific extension in a folder using batch script","author":"gantovnik","date":"2023-09-23","format":false,"excerpt":"[code language=\"python\"] @echo off set count=0 for \/f \"delims=\" %%i in ('dir \/s \/b *.fem') do ( set \/a \"count=count+1\" ) echo Number of fem files in the folder = %count% pause exit 0 [\/code] Output: [code language=\"python\"] Number of fem files in the folder = 20 Press any key\u2026","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":688,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/121-windows-batch-script-to-run-every-nastran-input-file-in-folder\/","url_meta":{"origin":907,"position":2},"title":"#121: Windows batch script to run every Nastran input file in folder","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"This is an example of a Windows bat file to run Nastran for every *.dat file in the current folder. It also calculates the total Nastran execution time. Of course, you should change the path to nastran.exe. The nice thing here is that script uses variable set MyPath=%cd%, so you\u2026","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":593,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/07\/87-batch-script-to-delete-empty-folders\/","url_meta":{"origin":907,"position":3},"title":"#87 One-line batch script to delete empty directories","author":"gantovnik","date":"2020-07-31","format":false,"excerpt":"#87 One-line batch script to delete empty directories: Variant 1 [code language=\"python\"] for \/f \"delims=\" %%i in ('dir \/s \/b \/ad ^| sort \/r') do rd \"%%i\">NUL [\/code] Variant 2 [code language=\"python\"] for \/f \"usebackq\" %%d in (`\"dir \/ad\/b\/s | sort \/R\"`) do rd \"%%d\" [\/code]","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9440,"url":"https:\/\/gantovnik.com\/bio-tips\/2025\/04\/459-python-script-to-group-consecutive-numbers-into-ranges-like-in-msc-patran\/","url_meta":{"origin":907,"position":4},"title":"#459 Python Script to Group Consecutive Numbers into Ranges Like in MSC Patran","author":"gantovnik","date":"2025-04-20","format":false,"excerpt":"This Python script reads a text file containing a list of numbers (such as node or element IDs), sorts them, removes duplicates, and groups consecutive numbers into compact ranges - just like MSC Patran's range format. It's a handy tool for preprocessing or organizing large ID lists efficiently. def read_numbers(filename):\u2026","rel":"","context":"In &quot;patran&quot;","block_context":{"text":"patran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/patran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":551,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/05\/write-variable-to-file-in-tcl\/","url_meta":{"origin":907,"position":5},"title":"Write variable to file in tcl","author":"gantovnik","date":"2020-05-26","format":false,"excerpt":"Write variable to file in tcl [code language=\"python\"] # create some data set data \"This is some test data.\\n\" # pick a filename - if you don't include a path, # it will be saved in the current directory set filename \"test.txt\" # open the filename for writing set fileId\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=907"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/907\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}