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

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…

Contents