{"id":2041,"date":"2022-02-23T10:27:56","date_gmt":"2022-02-23T10:27:56","guid":{"rendered":"https:\/\/dreid.nl\/?p=2041"},"modified":"2022-02-23T10:58:05","modified_gmt":"2022-02-23T10:58:05","slug":"how-to-read-input-from-a-file-in-a-batch-script","status":"publish","type":"post","link":"https:\/\/dreid.nl\/?p=2041","title":{"rendered":"How to read input from a file in a batch script"},"content":{"rendered":"<p>Windows batch scripts are incredibly useful for processing data. You can automate many tasks by a simple batch file. The most common thing that I use is a for loop over all files of a certain file name pattern, often extension:<\/p>\n<p><code>for %%I in (*.laz) do (<br \/>\ndo something with %%I<br \/>\n)<\/code><br \/>\nBut there are cases where it is required to not loop over all files, but only the files given in a text file, maybe after you have done something in Excel. Luckily, you can also loop through the lines in a file, and even split columns based on a delimiter and treat the individual columns as different arguments. Below script reads from a comma-separated file and uses the first columns as file name for processing with the <a href=\"https:\/\/dreid.nl\/?p=2044\">LAStools<\/a> command las2las, in this case setting the LAZ version and scaling the intensity.<\/p>\n<p><code>mkdir fixed<br \/>\n<\/code><code>for \/F \"tokens=1* delims=,\" %%I in (intensity.csv) do (<br \/>\nlas2las -i \"%%I\" -o \"fixed\\%%~nxI\" -set_version 1.2 -scale_intensity 0.0625<br \/>\n)<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows batch scripts are incredibly useful for processing data. You can automate many tasks by a simple batch file. The most common thing that I use is a for loop over all files of a certain file name pattern, often extension: for %%I in (*.laz) do ( do something with %%I ) But there are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[109],"class_list":{"0":"post-2041","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-blog","8":"tag-batch","9":"czr-hentry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to read input from a file in a batch script - DreiD BV<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dreid.nl\/?p=2041\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to read input from a file in a batch script - DreiD BV\" \/>\n<meta property=\"og:description\" content=\"Windows batch scripts are incredibly useful for processing data. You can automate many tasks by a simple batch file. The most common thing that I use is a for loop over all files of a certain file name pattern, often extension: for I ) But there are [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dreid.nl\/?p=2041\" \/>\n<meta property=\"og:site_name\" content=\"DreiD BV\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DreiDBV\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-23T10:27:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-23T10:58:05+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/dreid.nl\/wp-content\/uploads\/2022\/02\/batch.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"790\" \/>\n\t<meta property=\"og:image:height\" content=\"684\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tobias\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschreven door\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tobias\" \/>\n\t<meta name=\"twitter:label2\" content=\"Verwachte leestijd\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuut\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041\"},\"author\":{\"name\":\"Tobias\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/person\\\/724765ca445bdd176b5dfa6f0f432741\"},\"headline\":\"How to read input from a file in a batch script\",\"datePublished\":\"2022-02-23T10:27:56+00:00\",\"dateModified\":\"2022-02-23T10:58:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041\"},\"wordCount\":144,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/batch.jpg\",\"keywords\":[\"Batch\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/dreid.nl\\\/?p=2041#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041\",\"url\":\"https:\\\/\\\/dreid.nl\\\/?p=2041\",\"name\":\"How to read input from a file in a batch script - DreiD BV\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/batch.jpg\",\"datePublished\":\"2022-02-23T10:27:56+00:00\",\"dateModified\":\"2022-02-23T10:58:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/dreid.nl\\\/?p=2041\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#primaryimage\",\"url\":\"https:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/batch.jpg\",\"contentUrl\":\"https:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/batch.jpg\",\"width\":790,\"height\":684},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2041#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dreid.nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to read input from a file in a batch script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#website\",\"url\":\"https:\\\/\\\/dreid.nl\\\/\",\"name\":\"DreiD BV\",\"description\":\"3D printen en meer\",\"publisher\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/dreid.nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#organization\",\"name\":\"DreiD B.V.\",\"url\":\"https:\\\/\\\/dreid.nl\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"http:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/cropped-logo-vierkant.png\",\"contentUrl\":\"http:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/cropped-logo-vierkant.png\",\"width\":512,\"height\":512,\"caption\":\"DreiD B.V.\"},\"image\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/DreiDBV\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/person\\\/724765ca445bdd176b5dfa6f0f432741\",\"name\":\"Tobias\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g\",\"caption\":\"Tobias\"},\"url\":\"https:\\\/\\\/dreid.nl\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to read input from a file in a batch script - DreiD BV","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dreid.nl\/?p=2041","og_locale":"nl_NL","og_type":"article","og_title":"How to read input from a file in a batch script - DreiD BV","og_description":"Windows batch scripts are incredibly useful for processing data. You can automate many tasks by a simple batch file. The most common thing that I use is a for loop over all files of a certain file name pattern, often extension: for I ) But there are [&hellip;]","og_url":"https:\/\/dreid.nl\/?p=2041","og_site_name":"DreiD BV","article_publisher":"https:\/\/www.facebook.com\/DreiDBV","article_published_time":"2022-02-23T10:27:56+00:00","article_modified_time":"2022-02-23T10:58:05+00:00","og_image":[{"width":790,"height":684,"url":"http:\/\/dreid.nl\/wp-content\/uploads\/2022\/02\/batch.jpg","type":"image\/jpeg"}],"author":"Tobias","twitter_card":"summary_large_image","twitter_misc":{"Geschreven door":"Tobias","Verwachte leestijd":"1 minuut"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dreid.nl\/?p=2041#article","isPartOf":{"@id":"https:\/\/dreid.nl\/?p=2041"},"author":{"name":"Tobias","@id":"https:\/\/dreid.nl\/#\/schema\/person\/724765ca445bdd176b5dfa6f0f432741"},"headline":"How to read input from a file in a batch script","datePublished":"2022-02-23T10:27:56+00:00","dateModified":"2022-02-23T10:58:05+00:00","mainEntityOfPage":{"@id":"https:\/\/dreid.nl\/?p=2041"},"wordCount":144,"commentCount":0,"publisher":{"@id":"https:\/\/dreid.nl\/#organization"},"image":{"@id":"https:\/\/dreid.nl\/?p=2041#primaryimage"},"thumbnailUrl":"https:\/\/dreid.nl\/wp-content\/uploads\/2022\/02\/batch.jpg","keywords":["Batch"],"articleSection":["Blog"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dreid.nl\/?p=2041#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dreid.nl\/?p=2041","url":"https:\/\/dreid.nl\/?p=2041","name":"How to read input from a file in a batch script - DreiD BV","isPartOf":{"@id":"https:\/\/dreid.nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dreid.nl\/?p=2041#primaryimage"},"image":{"@id":"https:\/\/dreid.nl\/?p=2041#primaryimage"},"thumbnailUrl":"https:\/\/dreid.nl\/wp-content\/uploads\/2022\/02\/batch.jpg","datePublished":"2022-02-23T10:27:56+00:00","dateModified":"2022-02-23T10:58:05+00:00","breadcrumb":{"@id":"https:\/\/dreid.nl\/?p=2041#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dreid.nl\/?p=2041"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/dreid.nl\/?p=2041#primaryimage","url":"https:\/\/dreid.nl\/wp-content\/uploads\/2022\/02\/batch.jpg","contentUrl":"https:\/\/dreid.nl\/wp-content\/uploads\/2022\/02\/batch.jpg","width":790,"height":684},{"@type":"BreadcrumbList","@id":"https:\/\/dreid.nl\/?p=2041#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dreid.nl\/"},{"@type":"ListItem","position":2,"name":"How to read input from a file in a batch script"}]},{"@type":"WebSite","@id":"https:\/\/dreid.nl\/#website","url":"https:\/\/dreid.nl\/","name":"DreiD BV","description":"3D printen en meer","publisher":{"@id":"https:\/\/dreid.nl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dreid.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"},{"@type":"Organization","@id":"https:\/\/dreid.nl\/#organization","name":"DreiD B.V.","url":"https:\/\/dreid.nl\/","logo":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/dreid.nl\/#\/schema\/logo\/image\/","url":"http:\/\/dreid.nl\/wp-content\/uploads\/2017\/11\/cropped-logo-vierkant.png","contentUrl":"http:\/\/dreid.nl\/wp-content\/uploads\/2017\/11\/cropped-logo-vierkant.png","width":512,"height":512,"caption":"DreiD B.V."},"image":{"@id":"https:\/\/dreid.nl\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DreiDBV"]},{"@type":"Person","@id":"https:\/\/dreid.nl\/#\/schema\/person\/724765ca445bdd176b5dfa6f0f432741","name":"Tobias","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/secure.gravatar.com\/avatar\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g","caption":"Tobias"},"url":"https:\/\/dreid.nl\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts\/2041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2041"}],"version-history":[{"count":2,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts\/2041\/revisions"}],"predecessor-version":[{"id":2047,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts\/2041\/revisions\/2047"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/media\/2042"}],"wp:attachment":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}