{"id":683,"date":"2010-03-18T13:22:47","date_gmt":"2010-03-18T07:52:47","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=683"},"modified":"2010-11-13T03:01:36","modified_gmt":"2010-11-13T03:01:36","slug":"batch-script-to-add-remove-prefix-zero-pad-bulk-file-rename","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/batch-script-to-add-remove-prefix-zero-pad-bulk-file-rename","title":{"rendered":"batch script to add remove prefix zero pad bulk file rename"},"content":{"rendered":"<p>This post has two batch scripts:<br \/>\n<strong>1. Batch script to rename files with zero padded number series-prefix<\/strong><\/p>\n<p><strong> <\/strong><\/p>\n<p><strong>2. Batch script to remove prefix of perticular length<br \/>\n<\/strong><\/p>\n<h2>1. Batch script to rename files with zero padded number series-prefix<\/h2>\n<p>This script will accept file-type to be searched and lenght of zero-padded prefix to be attached.<\/p>\n<p>Usage: RenZeroPad.bat<\/p>\n<p>Consider you have to rename \/ arrange a lot of mp3 files in a perticular sequence:<\/p>\n<p>File names before execution:<br \/>\n<em>fileX.mp3<br \/>\nfileY.mp3<br \/>\nfileZ.mp3<\/em><\/p>\n<p>Command on dos prompt: RenZeroPad.bat mp3 4<\/p>\n<p>File names with attached prefix:<br \/>\n<em>0001 fileX.mp3<br \/>\n0002 fileY.mp3<br \/>\n0003 fileZ.mp3<\/em><\/p>\n<p style=\"text-align: right;\">[ad#ad-2-300&#215;250]<\/p>\n<p><strong>The Batch Script to add zero pad digits prefix:<\/strong><\/p>\n<p><em>@echo off<br \/>\nsetLocal EnableDelayedExpansion<\/em><\/p>\n<p><em> <\/em><\/p>\n<p>set \/a cnt=1<br \/>\nfor %%i in (*.%1) do (<br \/>\ncall :Set0Pad %2<\/p>\n<p>set newName=!str! %%i<br \/>\nren &#8220;%%i&#8221; &#8220;!newName!&#8221;<br \/>\n)<\/p>\n<p><em>:Set0Pad<br \/>\nset padcntr=0000000000%cnt%<br \/>\nset str=%padcntr:~-%1%<br \/>\nset renstr=%str%<br \/>\nset \/a cnt+=1<\/em><\/p>\n<p><em>** Download available at the end of the page.<\/em><\/p>\n<p style=\"text-align: right;\">\n<h2>2. Batch script to remove prefix of perticular length<\/h2>\n<p>This script will accept file-type to be searched and lenght of prefix to be removed.<\/p>\n<p>Usage: RemovePrefix.bat<\/p>\n<p>Consider you have to rename \/ remove prefixes from a bunch of files:<\/p>\n<p><em>0001_fileX.doc<br \/>\n0002_fileY.doc<br \/>\n0003_fileZ.doc<\/em><\/p>\n<p>Command on dos prompt: RemovePrefix.bat mp3 5<\/p>\n<p>Files will be renamed with removed prefixes as follows:<br \/>\n<em>fileX.doc<br \/>\nfileY.doc<br \/>\nfileZ.doc<\/em><\/p>\n<p><strong>The Batch Script to remove prefix:<br \/>\n<\/strong><\/p>\n<p><em>@echo off<br \/>\nsetLocal EnableDelayedExpansion<\/em><\/p>\n<p><em> <\/em><\/p>\n<p><em>set \/a cnt=1<br \/>\nfor %%i in (*.%1) do (<br \/>\nset str=%%i<br \/>\nset newstr=!str:~%2!<br \/>\nren &#8220;%%i&#8221; &#8220;!newstr!&#8221;<br \/>\n)<\/em><\/p>\n<p><strong>Download<\/strong>: <a href=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2010\/03\/removeprefix.bat_.txt\" target=\"_blank\">RemovePrefix.bat<\/a> and\u00a0<a href=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2010\/03\/renzeropad.bat_.txt\" target=\"_blank\">RenZeroPad.bat<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"This post has two batch scripts: 1. Batch script to rename files with zero padded number series-prefix 2. Batch script to remove prefix of perticular length 1. Batch script to&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6],"tags":[18,102,426,125],"class_list":{"0":"post-683","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-technical","7":"tag-batch","8":"tag-script","9":"tag-technical","10":"tag-windows"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":1,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":1345,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions\/1345"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}