In this video, learn how to copy, move, and rename your files with Node.js. The file system module provides easy methods for manipulating your file names and locations. The renameSync, unlinkSync, and removeName methods help you perform edits to files. Learn how to set up error messaging for all of these processes also in this video.
- You may need to move, … rename or remove a file. … The file system module has methods for that as well. … Let's go into our start folder and create a new file … called "rename.js." … The first thing I'm going to do is require the fs module … and the rename method has both a … synchronous and an asynchronous … version so "fs.renameSync" is the synchronous version … and I'll use that to rename a file. … I'm going to go ahead and rename the colors.json file … within my assets folder, … so the first argument is the path to the colors.json file. … That's the file that I want to rename and the second … argument is going to be the new name. … We'll call it colorData. … There's also an asynchronous version to the rename function, … and you can also use the rename function to move files. … So I'm going ahead and select the "./assets/notes.md" … and I can move that file simply by renaming the path, … so "./storage-files/notes.md." … As always, … with the asynchronous function, … the last argument is going to be the call back. …
- What is Node.js?
- Installing Node.js
- The global object
- Importing the core modules
- Creating custom events with the EventEmitter
- Reading, writing, and removing files
- Working with file streams
- Creating child processes with the exec and spawn functions
Skill Level Intermediate
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
1. What Is Node.js?
2. Set Up Your Environnment
3. Node Globals
4. Node Modules
5. File System Basics
6. Files and Streams
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.