1
00:00:00,180 --> 00:00:01,859
Hello there, you beautiful people.

2
00:00:01,859 --> 00:00:06,600
And welcome to this video where you're going to learn everything you need to know are all about moving

3
00:00:06,600 --> 00:00:10,170
and renaming files and directories using the command line.

4
00:00:10,170 --> 00:00:15,360
Now, the interesting thing is both of these functions can be completed with just one command.

5
00:00:15,360 --> 00:00:21,120
So in this video you're going to learn how to use the MV command to move and rename files and folders.

6
00:00:21,120 --> 00:00:25,890
And by learning the one command we're going to cover in this video, you're going to gain two very important

7
00:00:25,890 --> 00:00:28,050
abilities for working with your file system.

8
00:00:28,080 --> 00:00:29,340
Talk about efficiency, huh?

9
00:00:29,370 --> 00:00:31,920
So let's go ahead and get right into it.

10
00:00:33,840 --> 00:00:34,110
Okay.

11
00:00:34,200 --> 00:00:37,180
So let's first talk about renaming files.

12
00:00:37,200 --> 00:00:44,310
Now on the desktop, I have a file called Old Name txt and I want to rename it to be called new name.

13
00:00:44,550 --> 00:00:46,740
TXT very imaginative.

14
00:00:46,740 --> 00:00:47,350
I know.

15
00:00:47,370 --> 00:00:52,710
Now to do this to this rename, it's really very simple to do using the MV command.

16
00:00:52,710 --> 00:00:54,180
So first let me get to the desktop.

17
00:00:54,510 --> 00:00:57,660
So now I'm on the desktop where the files actually are.

18
00:00:57,690 --> 00:01:07,230
And to rename old name, to be new name, all I have to do is just do mzvee then old name dot txt,

19
00:01:07,230 --> 00:01:12,930
which is the current name of the file and then give it its new name which is new name dot txt.

20
00:01:12,960 --> 00:01:19,830
And when I press enter you'll see that the file has been renamed and we can see that using the LS command

21
00:01:19,830 --> 00:01:20,220
as well.

22
00:01:20,220 --> 00:01:21,390
It's now new name.

23
00:01:21,660 --> 00:01:23,310
TXT simple.

24
00:01:23,430 --> 00:01:25,410
And the same thing works for directories.

25
00:01:25,410 --> 00:01:27,890
So I have a folder here called old folder.

26
00:01:27,900 --> 00:01:32,280
And as we can see, old folder actually contains a few files.

27
00:01:32,280 --> 00:01:40,220
So it's got file one to file ten inside there now to rename old folder to be called new folder.

28
00:01:40,230 --> 00:01:47,580
And if I clear the screen, all I need to do is move old folder, new folder and when I press enter

29
00:01:47,850 --> 00:01:52,380
we can see that the folder has been renamed and it's just that simple.

30
00:01:52,530 --> 00:01:58,680
And even though we've just changed the name of the folder, if we open it up, all the files are still

31
00:01:58,680 --> 00:02:01,440
in there exactly as they were before.

32
00:02:01,440 --> 00:02:05,350
So renaming folders doesn't damage any of the contents inside.

33
00:02:05,370 --> 00:02:11,610
So with that said, how can we move files from one folder into another folder?

34
00:02:11,640 --> 00:02:13,470
This is also actually really simple.

35
00:02:13,500 --> 00:02:18,600
All we need to do is give the move command what we want to move and then the directory that we want

36
00:02:18,600 --> 00:02:19,280
to move them to.

37
00:02:19,290 --> 00:02:21,540
So this is very similar to the copy command.

38
00:02:21,750 --> 00:02:24,870
With the copy command, you gave it a list of all the things you wanted to copy.

39
00:02:24,870 --> 00:02:30,180
And then the final command line argument you gave it was where you wanted to move it, to copy it to

40
00:02:30,180 --> 00:02:30,630
sorry.

41
00:02:30,630 --> 00:02:32,580
And it's the same idea with the mov command.

42
00:02:32,970 --> 00:02:41,100
So if we want to move everything from a new folder onto the desktop, then all we'd have to do is say

43
00:02:41,100 --> 00:02:48,330
move from new folder, move new folder, everything in there to here, which is the desktop.

44
00:02:48,660 --> 00:02:54,420
So the dot remember means the current working directory and as you can see from the shell prompt, that

45
00:02:54,420 --> 00:02:55,140
is the desktop.

46
00:02:55,140 --> 00:02:59,850
So what we're saying is move everything from within new folder to the current working directory, which

47
00:02:59,850 --> 00:03:00,420
is the desktop.

48
00:03:00,420 --> 00:03:07,470
So if I press enter, you'll see that all of the files have been shifted onto onto the desktop, which

49
00:03:07,470 --> 00:03:08,610
we can see using LRS.

50
00:03:08,640 --> 00:03:14,490
We've got file 1 to 10 and if we look inside new folder, we can see that they haven't just been copied.

51
00:03:14,490 --> 00:03:19,260
They have indeed been moved because the folder is completely empty.

52
00:03:20,660 --> 00:03:20,860
Okay.

53
00:03:21,140 --> 00:03:24,620
So let's move all of these files back into a new folder.

54
00:03:24,620 --> 00:03:30,730
So if I move everything that starts with file back into new folder, that should take care of all that.

55
00:03:30,740 --> 00:03:31,430
So there we go.

56
00:03:31,430 --> 00:03:35,180
We've moved them all back into this new folder folder.

57
00:03:35,210 --> 00:03:40,310
Okay, now how can we move the whole of new folder just as one go?

58
00:03:40,310 --> 00:03:44,540
How can we move this into our documents folder, for example?

59
00:03:44,540 --> 00:03:46,010
Well, that's really easy to do as well.

60
00:03:46,250 --> 00:03:48,290
And it works just like you might expect.

61
00:03:48,290 --> 00:03:54,950
We just do move new folder and where's our destination where we want it to go into the documents folder,

62
00:03:54,950 --> 00:03:56,570
which is in our home directory.

63
00:03:56,570 --> 00:04:00,920
So we put the tilde to say our home directory slash and then documents.

64
00:04:00,920 --> 00:04:05,210
So the documents folder inside our home directory we press enter.

65
00:04:05,210 --> 00:04:10,850
And now when we look inside our home directory and go into our documents folder, there we are.

66
00:04:10,880 --> 00:04:15,740
There's new folder sitting there all, all intact.

67
00:04:15,740 --> 00:04:17,269
So now for the jackpot.

68
00:04:17,300 --> 00:04:24,230
How can I move new folder inside of documents or move it somewhere and rename it at the same time?

69
00:04:24,230 --> 00:04:31,160
So let's say I want to move it from our documents folder to the desktop and rename it to B jackpot at

70
00:04:31,160 --> 00:04:31,940
the same time.

71
00:04:31,940 --> 00:04:32,990
So how would we do that?

72
00:04:32,990 --> 00:04:34,670
Well, first we need to sell it.

73
00:04:34,700 --> 00:04:36,740
We need to tell the move command what we want to move.

74
00:04:36,740 --> 00:04:42,980
So let's say we want to move the new folder folder inside our our documents folder.

75
00:04:42,980 --> 00:04:46,910
And this this is something you should be comfortable with, by the way, using the tilde to represent

76
00:04:46,910 --> 00:04:51,620
your home folder, then documents, then new folder.

77
00:04:52,100 --> 00:04:55,880
This slash at the end is optional, but I think it comes with the tab auto completion.

78
00:04:55,880 --> 00:04:57,170
So we'll we'll leave it there.

79
00:04:57,200 --> 00:04:57,660
Okay.

80
00:04:57,710 --> 00:04:59,780
Now we're where do we want to move it to?

81
00:04:59,810 --> 00:05:05,900
We want to move it to our desktop so we could say this current working directory because as you can

82
00:05:05,900 --> 00:05:10,730
see we're on the desktop so we're going to move it to current working directory, but we're going to

83
00:05:10,730 --> 00:05:13,580
call it jackpot.

84
00:05:14,480 --> 00:05:16,010
Sorry, jackpot.

85
00:05:16,010 --> 00:05:22,130
Now because the jackpot folder doesn't exist, new folder will become jackpot.

86
00:05:22,130 --> 00:05:26,930
So if I press enter, we'll see that jackpot has been created inside.

87
00:05:26,930 --> 00:05:30,800
There are all the content or every single one of the files from new folder.

88
00:05:30,800 --> 00:05:35,570
And if we go back in to our documents, we will see that new folder is no longer there.

89
00:05:35,570 --> 00:05:36,590
So what happened?

90
00:05:36,590 --> 00:05:43,730
We said move the new folder folder from within our documents folder and put it in this directory, which

91
00:05:43,730 --> 00:05:47,930
is the desktop, but as of as a folder called jackpot.

92
00:05:47,930 --> 00:05:52,190
So that is how you can move a folder and rename it at the same time.

93
00:05:52,190 --> 00:05:53,450
Pretty awesome stuff, right?

94
00:05:54,960 --> 00:05:55,990
So there you have it.

95
00:05:56,010 --> 00:06:01,200
The MV command is a very simple but very effective command for anything that you'll ever need to do

96
00:06:01,200 --> 00:06:03,110
with moving or renaming files.

97
00:06:03,120 --> 00:06:08,040
And in this video, you've seen how to move and rename files and directories using the MV command,

98
00:06:08,040 --> 00:06:09,150
and this is how it works.

99
00:06:09,150 --> 00:06:15,000
So if you want to move files and directories, first you type the MV command, then you give it as command

100
00:06:15,000 --> 00:06:18,720
line arguments, everything that you want to move and you can give it multiple of those.

101
00:06:18,720 --> 00:06:23,220
And then the final command line argument is the destination of where you want to move all of those things

102
00:06:23,220 --> 00:06:23,700
to.

103
00:06:23,700 --> 00:06:28,740
And if you want to rename files and directories, we can only do one at a time, but you give it what

104
00:06:28,740 --> 00:06:34,830
you want to rename and then the new name and location if you want to move and rename at the same time.

105
00:06:34,830 --> 00:06:36,840
And you've seen her to do that in this video.

106
00:06:36,840 --> 00:06:42,450
So just remember that if you ever want to move or rename a file, the MV command is what you need.

107
00:06:42,450 --> 00:06:46,470
So in the last few videos you've learned how to modify the file tree quite a lot.

108
00:06:46,470 --> 00:06:50,820
You can now create files and directories using the touch and mkdir commands.

109
00:06:50,820 --> 00:06:54,780
You can delete files and directories using the M and RMD commands.

110
00:06:54,780 --> 00:06:59,520
You can copy files and directories using the CPP command and you can even move and rename files and

111
00:06:59,520 --> 00:07:01,320
directories using the MV command.

112
00:07:01,320 --> 00:07:06,150
Well, in the next video you're going to learn how to actually edit these files using the command line.

113
00:07:06,150 --> 00:07:10,110
Now, obviously, this is going to be something that you'll do all the time.

114
00:07:10,380 --> 00:07:13,890
So for all that good stuff, I'll see you in the next video.

