• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script that checks for jpg file

Contributor ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Hello everyone! How to check if in the "Mysubpasta" subfolder there are .jpg files and if true remove all.

TOPICS
Actions and scripting

Views

535

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Nov 20, 2017 Nov 20, 2017

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;

    }

Votes

Translate

Translate
Adobe
People's Champ ,
Nov 20, 2017 Nov 20, 2017

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;

    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

LATEST

Thank you r-bin! It worked very well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines