-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_tags.js
40 lines (37 loc) · 1.21 KB
/
remove_tags.js
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
const fs = require("fs");
const path = require("path");
const NodeID3 = require('node-id3');
let args = process.argv;
let pathToFix = args[2] || null;
if(!pathToFix){
console.log("No file path or directory path provided...");
}
else{
pathToFix = path.resolve(pathToFix);
fs.stat(pathToFix,(err,stat) => {
if(err && err.code == "ENOENT"){
console.log(`Error, path ${pathToFix} not found`);
}
else if(err){
console.log("Error: " + err.message);
}
else{
if(stat.isFile()){
let fileName = path.parse(pathToFix).name;
console.log(`Removing tags from ${fileName} ...`);
NodeID3.removeTags(pathToFix);
}
else if(stat.isDirectory()){
let files = fs.readdirSync(pathToFix);
for(file of files){
filePath = path.resolve(pathToFix,file);
let tmpStat = fs.statSync(filePath);
if(tmpStat.isFile()){
console.log(`Removing tags from ${file} ...`);
NodeID3.removeTags(filePath);
}
}
}
}
});
}