ma-map-path
v0.0.0
Published
使用node遍历文件
Downloads
2
Readme
Node.js - map-path
遍历目标文件夹下的所有文件,然后再根据文件的属性进行相关操作。
使用方法
const path = require('path');
var { mapPath, fs } = require('ma-map-path');
const ROOT_PATH = 'D:/web/www/fws'; //需要遍历的文件名
const DEST_PATH = `F:/fws`; //需要复制到的目标文件夹
/*
@params
stat: 当前文件的stat属性
NOW_PATH: 当前文件的源文件路径
DEST_PATH_NAME: 当前文件的目标文件路径
*/
function fileFn(stat, NOW_PATH, DEST_PATH_NAME) {
console.log(stat);
}
/*
@params
ROOT_PATH: 需要遍历的文件名
DEST_PATH: 需要复制到的目标文件夹
fileFn: 对当前文件需要执行的操作
*/
mapPath(ROOT_PATH, DEST_PATH, fileFn);