Can I rename a directory while moving?

QuestionsQuestions8 SkillsProBasic Files OperationsNov, 25 2025
072

Yes, you can rename a directory while moving it using the mv command. To do this, specify the new name in the destination path. Here’s the syntax:

mv /path/to/source_directory /path/to/destination/new_directory_name

Example

If you want to move a directory named old_folder to a new location and rename it to new_folder, you would use:

mv old_folder/ /path/to/destination/new_folder/

This command will move old_folder to the specified destination and rename it to new_folder in the process. Make sure that the destination path exists, or the command will rename old_folder to new_folder in the current directory.

0 Comments

no data
Be the first to share your comment!