Languages
[Edit]
EN

Node.js - get file names with extensions from array of paths

0 points
Created by:
Dexter
660

In this article, we would like to show you how to get file name with extension from path array in Node.js.

Quick solution:

 

Practical example

Edit

1. Import path module using:

2. Use path.basename() method with the path you want to get the filename from as an argument.

Practical example:

Output:

Note:

In this solution we used for...of loop to iterate through the paths array, but you can use any other method from the following article:

Alternative titles

  1. Node.js - get filenames with extensions from path array
  2. Node.js - get names of files with extension from path array
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join