The example in this article describes the function of NodeJS traversing files to produce a file list. Share it with everyone for your reference, the details are as follows:
Functional requirements: At work, we may often need to know the list of static files in the project to be published, and it would be too hard to retrieve and write them one by one.
# If you want to know the file list inside, is it painful? Maybe we will also have dos tree to get it.
Share here, know the file path through node, configure the remote path, copy and publish directly.
There are comments in the new filelist.js, so I won’t shiver.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
When we execute
1 |
|
, filelist.txt will be produced , the file contains the path we want.
Sometimes, we usually encounter files that cannot be deleted. Because the file depth is too long, rm _rf cannot be deleted, but we can do it through nodejs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
I hope this article will be helpful to everyone in nodejs programming.
For more NodeJS file traversal file production file list function examples and related articles, please pay attention to the PHP Chinese website!