Reputation: 1943
The issue I have an array of files which are as follows
[video.mp4, image.jgpeg, hello.png]
my issue is trying to find the complete path to every file, I have looked at other answers, most of them point me to use
path.dirname(fileName)
using the path module from Node JS, however I only get a relative and not the complete path to the file
Path Returned
/folder/video.mp4
Path Needed
/folder/subdirectory/video.mp4
I need to be able to see the full path including the directory its actually in and not just the relative path to it, if anyone can help me out it will be much appreciated!
Note I am not trying to find out if the path of the file exists, I am trying to find the actual path, this is not a duplicate of
How to check if a file (given by full path) exists? node js
Upvotes: 1
Views: 698
Reputation: 74
Give the glob
package a try. (link)
Get all the files in your directory, and check if your file is in there. If it is, you'll have your full path as well.
You can find how to recursively get all the files in a directory using Glob here:
https://stackoverflow.com/a/41462807/11568997
Upvotes: 2