{"id":19,"date":"2014-04-01T02:07:00","date_gmt":"2014-04-01T00:07:00","guid":{"rendered":"http:\/\/celilsemi.erkiner.com\/blog\/?p=19"},"modified":"2020-05-22T08:10:50","modified_gmt":"2020-05-22T06:10:50","slug":"bulk-rename-with-windows-powershell","status":"publish","type":"post","link":"https:\/\/celilsemi.erkiner.com\/blog\/bulk-rename-with-windows-powershell\/","title":{"rendered":"Bulk Rename with Windows Powershell"},"content":{"rendered":"<p><span style=\"line-height: 1.5em;\">I also know that there is third party applications which are really good at this job but if you wanna feel a little bit geeky like me, try this!!<\/span><\/p>\n<p>First let us assume that we have&nbsp;bunch of files together in a folder. &nbsp;Their name are pretty confusing and random because let&#8217;s say that we have downloaded them all. For our super important project we need their names to become meaningful and useful.<\/p>\n<figure style=\"width: 507px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2014\/04\/bulkrename.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"Bulk Rename\" src=\"http:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2014\/04\/bulkrename.png\" width=\"507\" height=\"252\"><\/a><figcaption class=\"wp-caption-text\">Before &#8211; After Rename<\/figcaption><\/figure>\n<p>1. Open Start menu (or start page) and type &#8220;powershell&#8221; to find Windows PowerShell and open it.<\/p>\n<p><em>You can also try to look for it in your start menu or&nbsp;C:\\WINDOWS\\system32\\WindowsPowerShell directory.&nbsp;<\/em><\/p>\n<p>2. Set working directory&nbsp;to the directory&nbsp;with your random files.<\/p>\n<p><em>You can use &#8220;cd [directory name]&#8221; for walking into the directory &#8220;cd ..&#8221; for going to outer directory.<\/em><\/p>\n<p>3. Decide what you want to create algorithm. In this post I will arrange the names &#8220;[random].html&#8221; as &#8220;page[number].php&#8221;<\/p>\n<pre>Dir *.html | ForEach-Object -begin { $count=1 } -process { rename-item $_ -NewName \"page$count.php\"; $count++ }<\/pre>\n<figure style=\"width: 593px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2014\/04\/powershellrename.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"Windows PowerShell Rename\" src=\"http:\/\/celilsemi.erkiner.com\/blog\/wp-content\/uploads\/2014\/04\/powershellrename.png\" width=\"593\" height=\"184\"><\/a><figcaption class=\"wp-caption-text\">Windows PowerShell Rename<\/figcaption><\/figure>\n<p><code>Dir *.html |<\/code> part is to get all the html files in that dir and create something sort of an array before processing.<\/p>\n<p><code>ForEach-Object<\/code> is to the process file by file.<\/p>\n<p><code>-begin { $count=1 }<\/code> mean we start counting from 1.<\/p>\n<p><code>-process { rename-item $_ -NewName \"page$count.php\";<\/code> part does the trick.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I also know that there is third party applications which are really good at this job but if you wanna feel a little bit geeky like me, try this!! First let us assume that we have&nbsp;bunch of files together in a folder. &nbsp;Their name are pretty confusing and random because let&#8217;s say that we have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[6],"tags":[12,11],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-software","tag-shell","tag-windows"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":2,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/celilsemi.erkiner.com\/blog\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}