Answer the question
In order to leave comments, you need to log in
How to solve the problem with the transfer of all elements?
function getFiles (dirPath, callback) {
fs.readdir(dirPath, function (err, files) {
if (err) return callback(err);
var filePaths = [];
async.eachSeries(files, function (fileName, eachCallback) {
var filePath = path.join(dirPath, fileName);
fs.stat(filePath, function (err, stat) {
if (err) return eachCallback(err);
if (stat.isDirectory()) {
getFiles(filePath, function (err, subDirFiles) {
if (err) return eachCallback(err);
filePaths = filePaths.concat(subDirFiles);
eachCallback(null);
});
} else {
if (stat.isFile() && /YouTube_Accounts_\d+.txt$/.test(filePath)) {
filePaths.push(filePath);
}
eachCallback(null);
}
});
}, function (err) {
callback(err, filePaths);
});
});
}
function getDirectories(path) {
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path+'/'+file).isDirectory();
});
}
fs.readFile("config.txt", "utf8",
function(error,data){
if(error) throw error;
limit = data.match(/limit: (\d+)/)
console.log('Set limit: ' + limit[1])
});
let dir_main;
getFiles('./', function (err, files) {
for (const item of getDirectories('./')) {
if (item.startsWith('YT')) {
dir_main = item
for (const item of files) {
const array = fs.readFileSync(item).toString().split("\n");
for (const item of array) {
let check = item.match(/Account (.+) Subs: (\d+)/)
if (check != null || check != undefined) {
if (Number(check[2]) > Number(limit[1])) {
fska.move('./' + dir_main, './result/' + dir_main, err => {
if(err) return console.error(err);
console.log('success!');
});
fska.copy('./' + dir_main, './result/' + dir_main, err => {
if(err) return console.error(err);
console.log('success!');
});
}
}
}
}
}
}
});
for (const item of array) {
let check = item.match(/Account (.+) Subs: (\d+)/)
if (check != null || check != undefined) {
if (Number(check[2]) > Number(limit[1])) {
fska.copy('./' + dir_main, './result/' + dir_main, err => {
if(err) return console.error(err);
console.log('success!');
});
}
}
if (Number(check[2]) > Number(limit[1])) {
fska.copy('./' + dir_main, './result/' + dir_main, err => {
if(err) return console.error(err);
console.log('success!');
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question