Can I rename files in different directories?

QuestionsQuestions8 SkillsProBasic Files OperationsAug, 31 2025
0104

Yes, you can rename files in different directories using the mv command by specifying the full path of the source file and the desired new path for the renamed file.

Here’s the syntax:

mv /path/to/old_directory/old_filename /path/to/new_directory/new_filename

For example, if you want to rename file1.txt located in /home/user/documents to file2.txt in /home/user/desktop, you would use:

mv /home/user/documents/file1.txt /home/user/desktop/file2.txt

This command moves (renames) file1.txt to file2.txt in the specified new directory.

Make sure you have the necessary permissions to access both directories. If you have any more questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!