Commit a14ea6df authored by wildfirecode's avatar wildfirecode

1

parent 99a4b5bc
...@@ -3,13 +3,15 @@ var walk = require("./walk"); ...@@ -3,13 +3,15 @@ var walk = require("./walk");
module.exports = (input, output) => { module.exports = (input, output) => {
walk(input, (err, result) => { walk(input, (err, result) => {
input=path.normalize(input);
output=path.normalize(output);
let count = 0; let count = 0;
let imgURLs = result.filter( let imgURLs = result.filter(
val => ['.jpg', '.png'].indexOf(path.extname(val)) != -1); val => ['.jpg', '.png'].indexOf(path.extname(val)) != -1);
imgURLs = imgURLs.map(val => { imgURLs = imgURLs.map(val => {
let inputSplited = input.split(path.sep); let inputSplited = input.split(path.sep);
let splited = val.split(path.sep); let splited = val.split(path.sep);
return splited.slice(inputSplited.length - 1).join(path.sep); return splited.slice(inputSplited.length).join(path.sep);
}) })
if (imgURLs.length == 0) { console.log('没有需要处理的图片.'); return; } if (imgURLs.length == 0) { console.log('没有需要处理的图片.'); return; }
console.log(`图片遍历完毕,共有${imgURLs.length}张`); console.log(`图片遍历完毕,共有${imgURLs.length}张`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment