From the course: Node.js Essential Training
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Renaming and removing directories - Node.js Tutorial
From the course: Node.js Essential Training
Renaming and removing directories
- [Instructor] In the last lesson, we used the file system modules rename method to rename and move files. So you can use that same method to rename and move directories as well. The first thing we'll do inside of this directory's file is we're going to say fs require our file system module. And the method we want to use from this is renameSync. We can use this to rename a directory. So we have some here for you. We have a folder called assets, logs, and we want to go ahead and move it to the accounts folder. We'll say assets/logs and accounts/logs is where we want to move this. Now, if we console log logs folder moved and we run node directories, this is going to say that this was moved and we see that this is here. Now, something to note too, is that this already had a file in it. So we can see that the file directory has been moved with all of the files in it. We also saw in the last video, how we've removed files…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Listing directory files2m 25s
-
(Locked)
Reading files2m 19s
-
(Locked)
Writing and appending files3m 22s
-
(Locked)
Creating directories2m 26s
-
(Locked)
Renaming and removing files3m 29s
-
(Locked)
Renaming and removing directories3m 57s
-
(Locked)
Readable file streams5m 47s
-
(Locked)
Writable file streams4m 47s
-
(Locked)
-