{"id":593,"date":"2020-07-31T04:28:24","date_gmt":"2020-07-31T11:28:24","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=593"},"modified":"2020-07-31T04:32:49","modified_gmt":"2020-07-31T11:32:49","slug":"87-batch-script-to-delete-empty-folders","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2020\/07\/87-batch-script-to-delete-empty-folders\/","title":{"rendered":"#87 One-line batch script to delete empty directories"},"content":{"rendered":"<p>#87 One-line batch script to delete empty directories:<\/p>\n<p>Variant 1<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfor \/f &quot;delims=&quot; %%i in ('dir \/s \/b \/ad ^| sort \/r') do rd &quot;%%i&quot;&gt;NUL\n<\/pre>\n<p>Variant 2<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfor \/f &quot;usebackq&quot; %%d in (`&quot;dir \/ad\/b\/s | sort \/R&quot;`) do rd &quot;%%d&quot;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#87 One-line batch script to delete empty directories: Variant 1 for \/f &quot;delims=&quot; %%i in (&#8216;dir \/s \/b \/ad ^| sort \/r&#8217;) do rd &quot;%%i&quot;&gt;NUL Variant 2 for \/f &quot;usebackq&quot; %%d in (`&quot;dir \/ad\/b\/s | sort \/R&quot;`) do rd &quot;%%d&quot;<\/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-593","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-9z","jetpack_likes_enabled":true,"jetpack-related-posts":[{"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":593,"position":0},"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":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":593,"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":851,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/01\/151-script-to-create-multi-volume-rar-archive-with-specific-size-of-each-volume\/","url_meta":{"origin":593,"position":2},"title":"#151 Script to create multi-volume rar archive with specific size of each volume","author":"gantovnik","date":"2021-01-27","format":false,"excerpt":"#151 Script to create multi-volume rar archive with a specific size of each volume. I request 3GB for each volume. Create a bat file with the following code: [code language=\"python\"] SET WINRAR=\"C:\\Program Files\\WinRAR\" for \/D %%f in (\"D:\\create_rars\\*\") do ( %WINRAR%\\RAR.exe a -ep1 -r -v3G -idcdp -t -df \"D:\\create_rars\\%%~nxf.rar\" \"%%f\"\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":609,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/08\/91-iterating-through-directories-and-files-inside-these-directories\/","url_meta":{"origin":593,"position":3},"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":2219,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/06\/431-hypermesh-python-script-to-create-nodes-using-coordinates-from-csv-file\/","url_meta":{"origin":593,"position":4},"title":"#431 HyperMesh python script to create nodes using coordinates from csv file","author":"gantovnik","date":"2024-06-24","format":false,"excerpt":"Finally, I read how to write a script for HyperMesh in python. In this example, the script reads the coordinates of points from a cvs file. [code language=\"python\"] import os import hm import hm.entities as e from hwx import gui import csv model=hm.Model() os.chdir(r\"D:\\projects\\wordpress\\ex431\") with open('ex431_coordinates.csv', mode ='r') as file:\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex431.png?resize=350%2C200&ssl=1","width":350,"height":200},"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":593,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/593","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=593"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/593\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}