Hello there, you beautiful people.
And welcome to this video where you're going to learn everything you need to know are all about moving
and renaming files and directories using the command line.
Now, the interesting thing is both of these functions can be completed with just one command.
So in this video you're going to learn how to use the MV command to move and rename files and folders.
And by learning the one command we're going to cover in this video, you're going to gain two very important
abilities for working with your file system.
Talk about efficiency, huh?
So let's go ahead and get right into it.
Okay.
So let's first talk about renaming files.
Now on the desktop, I have a file called Old Name txt and I want to rename it to be called new name.
TXT very imaginative.
I know.
Now to do this to this rename, it's really very simple to do using the MV command.
So first let me get to the desktop.
So now I'm on the desktop where the files actually are.
And to rename old name, to be new name, all I have to do is just do mzvee then old name dot txt,
which is the current name of the file and then give it its new name which is new name dot txt.
And when I press enter you'll see that the file has been renamed and we can see that using the LS command
as well.
It's now new name.
TXT simple.
And the same thing works for directories.
So I have a folder here called old folder.
And as we can see, old folder actually contains a few files.
So it's got file one to file ten inside there now to rename old folder to be called new folder.
And if I clear the screen, all I need to do is move old folder, new folder and when I press enter
we can see that the folder has been renamed and it's just that simple.
And even though we've just changed the name of the folder, if we open it up, all the files are still
in there exactly as they were before.
So renaming folders doesn't damage any of the contents inside.
So with that said, how can we move files from one folder into another folder?
This is also actually really simple.
All we need to do is give the move command what we want to move and then the directory that we want
to move them to.
So this is very similar to the copy command.
With the copy command, you gave it a list of all the things you wanted to copy.
And then the final command line argument you gave it was where you wanted to move it, to copy it to
sorry.
And it's the same idea with the mov command.
So if we want to move everything from a new folder onto the desktop, then all we'd have to do is say
move from new folder, move new folder, everything in there to here, which is the desktop.
So the dot remember means the current working directory and as you can see from the shell prompt, that
is the desktop.
So what we're saying is move everything from within new folder to the current working directory, which
is the desktop.
So if I press enter, you'll see that all of the files have been shifted onto onto the desktop, which
we can see using LRS.
We've got file 1 to 10 and if we look inside new folder, we can see that they haven't just been copied.
They have indeed been moved because the folder is completely empty.
Okay.
So let's move all of these files back into a new folder.
So if I move everything that starts with file back into new folder, that should take care of all that.
So there we go.
We've moved them all back into this new folder folder.
Okay, now how can we move the whole of new folder just as one go?
How can we move this into our documents folder, for example?
Well, that's really easy to do as well.
And it works just like you might expect.
We just do move new folder and where's our destination where we want it to go into the documents folder,
which is in our home directory.
So we put the tilde to say our home directory slash and then documents.
So the documents folder inside our home directory we press enter.
And now when we look inside our home directory and go into our documents folder, there we are.
There's new folder sitting there all, all intact.
So now for the jackpot.
How can I move new folder inside of documents or move it somewhere and rename it at the same time?
So let's say I want to move it from our documents folder to the desktop and rename it to B jackpot at
the same time.
So how would we do that?
Well, first we need to sell it.
We need to tell the move command what we want to move.
So let's say we want to move the new folder folder inside our our documents folder.
And this this is something you should be comfortable with, by the way, using the tilde to represent
your home folder, then documents, then new folder.
This slash at the end is optional, but I think it comes with the tab auto completion.
So we'll we'll leave it there.
Okay.
Now we're where do we want to move it to?
We want to move it to our desktop so we could say this current working directory because as you can
see we're on the desktop so we're going to move it to current working directory, but we're going to
call it jackpot.
Sorry, jackpot.
Now because the jackpot folder doesn't exist, new folder will become jackpot.
So if I press enter, we'll see that jackpot has been created inside.
There are all the content or every single one of the files from new folder.
And if we go back in to our documents, we will see that new folder is no longer there.
So what happened?
We said move the new folder folder from within our documents folder and put it in this directory, which
is the desktop, but as of as a folder called jackpot.
So that is how you can move a folder and rename it at the same time.
Pretty awesome stuff, right?
So there you have it.
The MV command is a very simple but very effective command for anything that you'll ever need to do
with moving or renaming files.
And in this video, you've seen how to move and rename files and directories using the MV command,
and this is how it works.
So if you want to move files and directories, first you type the MV command, then you give it as command
line arguments, everything that you want to move and you can give it multiple of those.
And then the final command line argument is the destination of where you want to move all of those things
to.
And if you want to rename files and directories, we can only do one at a time, but you give it what
you want to rename and then the new name and location if you want to move and rename at the same time.
And you've seen her to do that in this video.
So just remember that if you ever want to move or rename a file, the MV command is what you need.
So in the last few videos you've learned how to modify the file tree quite a lot.
You can now create files and directories using the touch and mkdir commands.
You can delete files and directories using the M and RMD commands.
You can copy files and directories using the CPP command and you can even move and rename files and
directories using the MV command.
Well, in the next video you're going to learn how to actually edit these files using the command line.
Now, obviously, this is going to be something that you'll do all the time.
So for all that good stuff, I'll see you in the next video.