-
Notifications
You must be signed in to change notification settings - Fork 0
/
generatedel.js
56 lines (51 loc) · 1.35 KB
/
generatedel.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var fs = require("fs"),
http = require("http"),
url = require("url"),
path = require("path");
var request = require('request');
const md5File = require('md5-file');
var buf = fs.readFileSync('userdata.txt', "utf8");
if (! buf){
console.log('ERROR: no user data found plz enter userdata');
}
else{
fs.writeFileSync('dellist.html', '2"""');
var curr=__dirname;
var tpath = path.resolve(curr+'/remove_from_share');
//console.log(testFolder);
recurse(tpath,'/my_shared_videos');
}
function recurse(tpath, url){
fs.readdir(tpath, (err, files) => {
if(files.length == 0)
console.log('NO FILES TO DELETE in '+tpath);
else{
files.forEach(file => {
//console.log(tpath+'\\'+file);
fs.stat(path.resolve(tpath+'/'+file), function(err, stats) {
if(err)
console.log(err);
else{
if(stats.isDirectory()){
recurse(path.resolve(tpath+'/'+file),url+'/'+file);
}
else{
console.log(url+'/'+file);
md5File(path.resolve(tpath+'/'+file), (err, hash) => {
if (err)
{
console.log(err);
console.log("error in md5");
}
//console.log(file);
var data = hash + "$$$";
fs.appendFileSync('dellist.html', data);
console.log(data);
});
}
}
});
});
}
});
}