{"id":609,"date":"2020-08-13T00:19:15","date_gmt":"2020-08-13T07:19:15","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=609"},"modified":"2020-08-13T00:19:15","modified_gmt":"2020-08-13T07:19:15","slug":"91-iterating-through-directories-and-files-inside-these-directories","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2020\/08\/91-iterating-through-directories-and-files-inside-these-directories\/","title":{"rendered":"#91 Iterating through directories and files inside these directories"},"content":{"rendered":"<p>#91 Iterating through directories and files inside these directories<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\nset myDir=&quot;D:\\lib&quot;\nfor \/d %%B in (%myDir%\\*) do (\n@for %%C in (&quot;%%B\\*.dat&quot;) do echo %%C)\npause\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#91 Iterating through directories and files inside these directories set myDir=&quot;D:\\lib&quot; for \/d %%B in (%myDir%\\*) do ( @for %%C in (&quot;%%B\\*.dat&quot;) do echo %%C) pause<\/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_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":"","jetpack_post_was_ever_published":false},"categories":[17],"tags":[],"class_list":["post-609","post","type-post","status-publish","format-standard","hentry","category-batch"],"modified_by":null,"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-9P","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":607,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/08\/90-iterating-through-groups-of-files\/","url_meta":{"origin":609,"position":0},"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":[]},{"id":593,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/07\/87-batch-script-to-delete-empty-folders\/","url_meta":{"origin":609,"position":1},"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":1781,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/01\/339-nested-gridspec-using-python\/","url_meta":{"origin":609,"position":2},"title":"#339 Nested GridSpec using python","author":"gantovnik","date":"2023-01-16","format":false,"excerpt":"ex339.py [code language=\"python\"] import numpy as np import matplotlib.pyplot as plt def squiggle_xy(a, b, c, d, i=np.arange(0.0, 2*np.pi, 0.05)): return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d) fig11 = plt.figure(figsize=(8, 8), constrained_layout=False) outer_grid = fig11.add_gridspec(4, 4, wspace=0, hspace=0) for a in range(4): for b in range(4): # gridspec inside gridspec inner_grid = outer_grid[a, b].subgridspec(3, 3,\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\/2023\/01\/ex339.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/01\/ex339.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/01\/ex339.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/01\/ex339.png?resize=700%2C400&ssl=1 2x"},"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":609,"position":3},"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":867,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/156-filtering-content-from-files-using-awk\/","url_meta":{"origin":609,"position":4},"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":785,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/136-files-in-tcl\/","url_meta":{"origin":609,"position":5},"title":"#136 Files in tcl","author":"gantovnik","date":"2020-11-12","format":false,"excerpt":"#136 Files in tcl It is possible to convert a filename to the Tcl format. Notice the curly braces around the filename so that the \\ character isn\u2019t interpreted as the escape character. [code language=\"python\"] set filename {C:\\My_files\\readme.txt}; C:\\My_files\\readme.txt file join [file nativename $filename]; C:\/My_files\/readme.txt [\/code] While not recommended, it\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/609","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=609"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/609\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}