Copy link to clipboard
Copied
Hello everyone! How to check if in the "Mysubpasta" subfolder there are .jpg files and if true remove all.
var folder = new Folder("Mysubpasta"); // specify the full path, for example "C:\\Mysubpasta"
var files = folder.getFiles(mask);
alert(files.length);
for (var i = 0; i < files.length; i++) files.remove();
function mask(file)
{
var n = file.fsName.lastIndexOf(".");
if (n < 0) return false;
if (file.fsName.substr(n+1).search(/jpg/i) >=0) return true;
return false;
}
Copy link to clipboard
Copied
var folder = new Folder("Mysubpasta"); // specify the full path, for example "C:\\Mysubpasta"
var files = folder.getFiles(mask);
alert(files.length);
for (var i = 0; i < files.length; i++) files.remove();
function mask(file)
{
var n = file.fsName.lastIndexOf(".");
if (n < 0) return false;
if (file.fsName.substr(n+1).search(/jpg/i) >=0) return true;
return false;
}
Copy link to clipboard
Copied
Thank you r-bin! It worked very well.