{"id":8085,"date":"2021-07-10T12:30:20","date_gmt":"2021-07-10T12:30:20","guid":{"rendered":"https:\/\/linuxways.net\/?p=8085"},"modified":"2021-07-10T12:30:20","modified_gmt":"2021-07-10T12:30:20","slug":"how-to-rename-directories-in-linux-mint-20","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/mint\/how-to-rename-directories-in-linux-mint-20\/","title":{"rendered":"How to Rename Directories in Linux Mint 20"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Maintaining a structured file system is a necessity rather than a recommendation for system administrators. In this article, you will learn how to rename your directories in Linux Mint 20 to organize your files.<\/p>\n<h2>Find Your Current Working Directory<\/h2>\n<p>First of all, you will need your directory path\/name to follow this tutorial. In case you do not know your current directory, run the following command in the terminal.<\/p>\n<pre>pwd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"125\" class=\"wp-image-8086\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-215.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-215.png 880w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-215-300x43.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-215-768x109.png 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/p>\n<h2>List Down Directories\/Files in Your Current Directory<\/h2>\n<p>List down all the directories and files in your current directory and verify the renamed directories with the following command.<\/p>\n<pre>ls<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1486\" height=\"150\" class=\"wp-image-8087\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-216.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-216.png 1486w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-216-300x30.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-216-1024x103.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-216-768x78.png 768w\" sizes=\"auto, (max-width: 1486px) 100vw, 1486px\" \/><\/p>\n<h2>Rename Directories Using mv Command<\/h2>\n<p>To change your directory name, use the following mv command with your source and target directory.<\/p>\n<pre>mv &lt;source_directory&gt; &lt;target_directory&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1768\" height=\"150\" class=\"wp-image-8088\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-217.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-217.png 1768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-217-300x25.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-217-1024x87.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-217-768x65.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-217-1536x130.png 1536w\" sizes=\"auto, (max-width: 1768px) 100vw, 1768px\" \/><\/p>\n<p>You can see the results in listing down your directory contents. In the above snippet, you can see that the former \u2018test\u2019 directory is renamed to \u2018testdirectory\u2019.<\/p>\n<h2>Rename Directories Using rename Command<\/h2>\n<p>Alternatively, you can use the rename command to rename directories which is a more detailed built-in command.<\/p>\n<p>To change a directory name, run the following command.<\/p>\n<pre>rename \u2018s\/&lt;old-name&gt;\/&lt;new-name&gt;\/\u2019 *<\/pre>\n<p>As a result, you can see the \u2018test0\u2019 directory was renamed to \u2018directory\u2019 in the following snippet.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1833\" height=\"200\" class=\"wp-image-8089\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-218.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-218.png 1833w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-218-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-218-1024x112.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-218-768x84.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-218-1536x168.png 1536w\" sizes=\"auto, (max-width: 1833px) 100vw, 1833px\" \/><\/p>\n<p>Rename command can be used to rename multiple directories and files names at once. For example, you can change all the directory&#8217;s names to lowercase with the following command.<\/p>\n<pre>rename 'y\/A-Z\/a-z\/' *<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"174\" class=\"wp-image-8090\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-219.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-219.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-219-300x25.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-219-1024x87.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-219-768x65.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-219-1536x131.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<h2>Rename multiple Directories With find Command<\/h2>\n<p>For more complex renaming purposes, you can use the find command in combination with mv and rename command.<\/p>\n<p>Note: mv command can only rename a single directory at a time. To make multiple changes you need to run it in combination with the find command.<\/p>\n<p>Run the following command to change a directory name.<\/p>\n<pre>find . -depth -type d -name &lt;source_directory&gt; -execdir mv {} &lt;target_directory&gt; \\;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1673\" height=\"150\" class=\"wp-image-8091\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-220.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-220.png 1673w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-220-300x27.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-220-1024x92.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-220-768x69.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-220-1536x138.png 1536w\" sizes=\"auto, (max-width: 1673px) 100vw, 1673px\" \/><\/p>\n<p>\u2018-type\u2019 option will look for the directory while \u2018-exexdir\u2019 option will let the directory be renamed with mv command.<\/p>\n<p>You can make filesystem-wide directory changes with the find command. It comes in handy in particular, when you do not know where your targeted directory lies.<\/p>\n<p>In the following command, the find command is run in combination with the rename command to change all directory names to lowercase.<\/p>\n<pre>find . -mindepth 1 -prune -type d | rename 'y\/A-Z\/a-z\/'<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"194\" class=\"wp-image-8092\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-221.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-221.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-221-300x28.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-221-1024x97.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-221-768x73.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-221-1536x146.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>Keeping an organized file system brings merit not only to system administrators, but regular users can also benefit from it. In this article, you have learned all the ways you can organize your directories in your Linux Mint system.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction Maintaining a structured file system is a necessity rather than a recommendation for system administrators. In this article, you will learn how to rename your directories in&hellip;<\/p>","protected":false},"author":1,"featured_media":8256,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[47,129],"class_list":["post-8085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mint","tag-directories","tag-linux-mint-20"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=8085"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8085\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/8256"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=8085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=8085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=8085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}