{"id":1969,"date":"2023-09-23T03:01:49","date_gmt":"2023-09-23T10:01:49","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1969"},"modified":"2023-09-23T03:01:49","modified_gmt":"2023-09-23T10:01:49","slug":"393-count-the-number-of-files-with-a-specific-extension-in-a-folder-using-batch-script","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2023\/09\/393-count-the-number-of-files-with-a-specific-extension-in-a-folder-using-batch-script\/","title":{"rendered":"#393 Count the number of files with a specific extension in a folder using batch script"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n@echo off\r\nset count=0\r\nfor \/f &quot;delims=&quot; %%i in ('dir \/s \/b *.fem') do (\r\n  set \/a &quot;count=count+1&quot;\r\n)\r\necho Number of fem files in the folder = %count%\r\npause\r\nexit 0\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nNumber of fem files in the folder = 20\r\nPress any key to continue . . .\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>@echo off set count=0 for \/f &quot;delims=&quot; %%i in (&#8216;dir \/s \/b *.fem&#8217;) do ( set \/a &quot;count=count+1&quot; ) echo Number of fem files in the folder = %count% pause exit 0 Output: Number of fem files in the folder = 20 Press any key to continue . . .<\/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-1969","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-vL","jetpack_likes_enabled":true,"jetpack-related-posts":[{"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":1969,"position":0},"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":907,"url":"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\/","url_meta":{"origin":1969,"position":1},"title":"#164 Batch script to create md5 hash for every file in the folder, then write them to the text file","author":"gantovnik","date":"2021-05-05","format":false,"excerpt":"#164 Batch script to create md5 hash for every file in the folder, then write them in text file [code language=\"python\"] @echo off FOR \/F \"delims=\" %%F IN ('dir \/B \/A \/S *') DO ( for %%D in (\"%%~dpF\\.\") do ( set filename=%%~nxD.md5 ) ) TYPE NUL > %filename% For\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":1090,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/189-mandelbrot-set-using-python\/","url_meta":{"origin":1969,"position":2},"title":"#189 Mandelbrot set using python","author":"gantovnik","date":"2021-11-13","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt # This determines the number of colors used in the plot. # The larger the value, the longer the script will take. max_iterations = 50 # These parameters define the boundaries of the plot x_min, x_max = -2.5, 1.5 y_min,\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex189.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex189.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex189.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex189.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex189.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex189.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":867,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/156-filtering-content-from-files-using-awk\/","url_meta":{"origin":1969,"position":3},"title":"#156 Filtering content from files using awk","author":"gantovnik","date":"2021-02-09","format":false,"excerpt":"#156 Displaying and filtering the content of files with awk Using the following command, we can print all lines from the file: [code language=\"python\"] awk ' { print } ' \/etc\/passwd [\/code] This is equivalent to using the $0 variable. The $0 variables refers to the complete line. [code language=\"python\"]\u2026","rel":"","context":"In &quot;awk&quot;","block_context":{"text":"awk","link":"https:\/\/gantovnik.com\/bio-tips\/category\/awk\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":609,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/08\/91-iterating-through-directories-and-files-inside-these-directories\/","url_meta":{"origin":1969,"position":4},"title":"#91 Iterating through directories and files inside these directories","author":"gantovnik","date":"2020-08-13","format":false,"excerpt":"#91 Iterating through directories and files inside these directories [code language=\"python\"] set myDir=\"D:\\lib\" for \/d %%B in (%myDir%\\*) do ( @for %%C in (\"%%B\\*.dat\") do echo %%C) pause [\/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":607,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/08\/90-iterating-through-groups-of-files\/","url_meta":{"origin":1969,"position":5},"title":"#90 Iterating through groups of files","author":"gantovnik","date":"2020-08-13","format":false,"excerpt":"#90 Iterating through groups of files [code language=\"python\"] REM Iterating through groups of files for %%B in (D:\\projects\\bat\\test\\*.txt) do (echo %%B) pause [\/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":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1969","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=1969"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1969\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}