I am looking for some help creating a BAT file to help delete videos and images over a certain filename length.
A bit of background:
We have a custom made application and we do not have the source code. it updates its videos from a feed. recently we have been getting "buffer overrun detected" errors. we believe that the file names longer than 90 characters are becoming an issue.
I would like to remove these WMV and JPG files before they become a problem. We usually use bat files to perform these small tasks.
Don't stick to something OS -specific, use scripting language that would run on any platform, e.g. Node.js
var fs = require("fs");
var folderName = __dirname; // for current folder
var maxlength = 90;
function getFiles(dir, files_) {
files_ = files_ || [];
var files = fs.readdirSync(dir);
for ( var i in files) {
var name = dir + '/' + files[i];
if (fs.statSync(name).isDirectory()) {
getFiles(name, files_);
} else {
files_.push(name);
}
}
return files_;
}
var files = getFiles(folderName);
console.log(files);
for (var i = 0; i < files.length; i++) {
filename = files[i];
if (filename.length > maxlength) {
console.log("Deleting " + filename);
fs.unlinkSync(filename);
}
}