![]() In this script, we are listing all the files and directories that are located in the current working folder (where the script is located). Save this script as “change_name” and add it to your PATH environment variable if you want to use it on your entire system. depth -type d -name -execdir mv _temp" || echo 'Could not rename '"$directory"'' You can then remove your directories by executing the “mv” command with the “-execdir” option. In order to find and rename directories on Linux, use the “find” command with the “type” option in order to look for directories. ![]() Luckily for you, there is a command that helps you find and locate directories on a Linux system : the find command. In some cases, you may not know directly where your directories are located on your system. $ ls -l /home/userĭrwxr-r-x 2 user user 4096 Nov 9 16:41 Desktop/ĭrwxr-xr-x 2 user user 4096 Nov 9 16:41 Documents/ĭrwxr-xr-x 2 user user 4096 Nov 9 16:41 Downloads/ĭrwxr-xr-x 2 user user 4096 Nov 9 16:41 Music/ĭrwxrwxr-x 2 user user 4096 Dec 20 10:53 directory/Īwesome, you just renamed a directory on Linux. Now if you take a look at all the directories stored in your home directory, you will see a new entry for your “directory” folder. Note : using the mv command will not delete the content stored inside your directories, you won’t lose any files by renaming your directories on Linux. $ mv /home/user/temp /home/user/directory To rename this directory, you would use the “ mv” command and specify the two directory names. $ mv įor example, let’s say that you want to rename a specific directory on your filesystem named “temp” (located in your home directory) to “directory” (also in your home directory) To rename a directory on Linux, use the “mv” command and specify the directory to be renamed as well as the destination for your directory.
0 Comments
Leave a Reply. |