Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Renaming Files

00:00 Okay, so now you are back in the pb_terminal/ folder. There is a subdirectory called hello/, and in there is a file called hello_terminal.py.

00:10 And in our current folder, there’s also a file named hello_terminal. I want you to rename this file now into hello_world.py. All right. For this, I will use the move command. mv stands for move, and then I start off by giving it the file I want to rename, or folder, and then as a second command—so I’ll separate it with a space—I can put what I want to name it. And you said hello_world.py.

00:40 So, after executing this command, when I now list the contents, you see that the filename hello_terminal changed to hello_world. Okay.

00:47 And it’s still the same file,

00:51 so it still contains "Hello, Terminal!". Okay, so that now was was very interesting because I would’ve expected something like, I don’t know, rn or something for rename, but the mindset here is basically you are moving one file to some target location. So, you could, for example, move this file into the subdirectory as well. Before, we copied the file, but we could also move the file there.

01:17 And with this command, you can also rename the file in the same go, basically. And since you’re not putting it into a subdirectory, but into the same directory, you’re basically, like, moving the file into the same directory and renaming it to hello_world. Yep. Okay, cool.

01:34 This is a very handy command. Like, if you want to rename something, just remember the filename in first and then the new filename as the second argument.

Become a Member to join the conversation.