What is everybody this is Jason with there's soapstar com and in this video we are going to learn how
to move files copy files and rename files.
All right so let's dive in and get started.
So we've been working in our terminal.
We've got a few commands we've done in here so let's go ahead and clear this out.
So again I'm just going to write.
Clear and press ENTER give us more space to work with.
All right so what we're going to learn first is how to move files.
So in the Finder what I'm going to do is I'm going to go back a directory I'm going to go back one more
and actually let's go ahead and stay in the directory fun that we've done here.
So from the from the root level of our directory fun let's go ahead and create a folder so you can see
here in the terminal that I'm in services.
All right.
So I need to go back to level and now I'm in the root level of this project that we're working in right
listed all out.
Everything looks good.
So let's create a folder and I'm going to call this.
So let's just make a directory and we'll call it just say that we want to store over javascript files
in here.
So I've just made this directory.
And you can see over here in the Finder that it's appeared and says I'm building this project I want
to organize a project a little bit better and I want to keep all my javascript files in this one directory
so we can do that through the terminal by moving the file.
And to do that we're going to type in the command and we move.
All right.
And then we need to grab the name of the file that we want to move.
So we're going to type in main J.S. and then now we've got to give it a location of where we want it
to go.
If I was to go ahead and press enter here the terminals are going to throw me in there and it says hey
dude you didn't give me a directory where you want me to move this.
So please specify something for me.
So let's do it again.
Let's take an beam main door.
Yes.
And where we want to move this is into our genius folder.
All right go ahead and press enter and you can see over here in the Finder that the file has disappeared
it's gone.
Where did it go.
Well done.
We moved it into the transcript file So pretty cool.
There it is.
All right.
And then we can move files around anywhere we want.
And what I want to show you now is how to move a file back to where it was and we can do this.
This is a little bit tricky.
Make sure that we're in the James file so we've got to change her directory so CD J us Leslie out.
We can see our file in here and we're going to do.
Nvm the main dot J S file and what we have to do is we need to go back a directory so remember how we
use the CD command space dot dot.
Well we're going to do the same thing the DOT DOT allows us to go back a level.
So I'm going to hit dot dot for Slash.
This is going to give me the path where I want to go and where we want to go is directory fun.
So in the terminal Let's go ahead and type that out directory fun.
So we're going to take this file and we're going to move it back.
All right.
It looks like we have something really goofy happen here.
So we didn't even move our main Jap's file into our directory fun directory.
What it actually did is it created a directory fun file without an extension.
And the reason it did this is because you can actually use this same command M.V. to rename a file.
So technically what I said here is I said hey in the javascript directory and take the main js file
move it back a directory and rename it to directory fun.
So that's what happened here.
So let me show you how to actually properly do this so we're in our javascript our Jasc directory still.
So let me come back to here.
I'm going to create the file again.
Yes.
All right so now it's here.
So let's try this again.
We're going to do nvm main dot J Yes.
And we're simply going to do that dot dot forward slash.
We're just going to leave it at that because that way it puts it into the Directory fun here.
So now when we come back over to our directory now you'll see the file is here.
Now let me explain a little bit further why it created this file here in the JSM going to create another
file we'll just call this awesome dot Jess.
All right.
What I was saying and this command is well what I was trying to say is move this file back into a directory
which technically didn't exist.
So a directory that does exist is this services in our directory bun.
So what I could do with this is I could say move the awesome J us back a directory into the services
directory.
And if I hit enter you can see that the file isn't in here anymore.
If we go into our services you can see that the awesome jazz file has now been moved.
So pretty cool stuff here.
So we've covered how to move a file.
Let me show you how to copy a file.
So let's find a file that we want to copy here.
Let's say that this.
Let's see we have here.
Let's create another folder or another file.
So let's go back a level where in our directory fun we're going to create a file called Master dodgiest
and say this is a master template of some specific crazy function in our code project whatever.
Right.
So what we want to do is say we want to use this template in other parts of our project.
OK like another component per se.
And we're going to move it over into our services so or copy it into our services because we want it
to also stay in this root level directory fun.
So we're going to use the command C.P. to copying.
And then we're going to grab the name of the file master dot J.S. and then we're going to specify the
directory we wanted to go into which will just in this example call it services and we're going to hit
enter.
Now if we come into our services you will see that we have the master js file and this is this is cool
because when you're working with different frameworks like angular to for example you're working with
a lot of components you might have a typescript file that might be some master like template for a component
per se and you could go ahead and use this copy command to copy the entire file into that component
to set up like us a skeleton for you.
All right.
So pretty easy stuff.
Now the last thing that I want to cover is how to rename a file.
Let's see say this awesome J.S. file here.
Very poorly named it doesn't really specify anything that we're trying to do.
So let's go ahead and change the name of that.
So paying attention in our terminal we're in the directory fun.
So we need to get into our services.
So we're going to change the directory here and to rename a file We're going to use the same.
And the command that we use for move.
And then we're going to say we want to take the file awesome J.S. and let's rename it to cats just because
that makes way more sense.
All right.
And you can see the file has change right before our eyes.
So very powerful stuff.
Again this is stuff that you're going to be using all the time.
You've got to know how to move files around copy things around and also rename things in case you need
a better naming convention for some of the files you're working with.
So that is a wrap for this video.
Let's move on.