DS_Store files can you ignore via file mask?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

smathis

DS_Store files can you ignore via file mask?

Post by smathis »

Recently after updating to Mountain Lion I've seen some DS_Store files popping up, and while I know there are ways/tools to remove them... I was wondering is there a way to ignore them via your file masking? I've tried standard file masking and even updated via some recommendations using:

Code: Select allfileList.hidden == false

But this doesn't seem to work on DS_store files and I'm not sure why these don't work. Naming it specifically does not seem to do the trick either. Does anyone have some tips on how to ignore these in a script, or is it best just to strip these out with Onyx/TinkerTool or similar toolset and use terminal to prevent their generation?

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

DS_Store files can you ignore via file mask?

Post by Mike Hale »

You should be able to do a string match on 'DS_store' to exclude those files from being processed.

I think a better approach is to either use search mask in getFiles() to limit the results to only the image formats you want you script to support or to test each file to make sure it's a valid image format. That seems to me easier than having a long set of conditions for excluding a non image file.
xbytor

DS_Store files can you ignore via file mask?

Post by xbytor »

Here is code that I use for image file selection. Since it is only looking for know image types, it skips .DS_store automatically.
The f.name.slice(0,2) != "._" bit is in there when a mac file system is mounted on a win box and skips the automatically generated thumbnails.

Code: Select allImageProcessor.isValidImageFile = function(f) {
  function _winCheck(f) {
    // skip mac system files
    if (f.name.slice(0,2) != "._") {
      return false;
    }

    var ext = f.strf('%e').toUpperCase();
    return (ext.length > 0) && app.windowsFileTypes.contains(ext);
  }
  function _macCheck(f) {
    return app.macintoshFileTypes.contains(f.type) || _winCheck(f);
  }

  return (((File.fs == "Macintosh") && _macCheck(f)) ||
          ((File.fs == "Windows") && _winCheck(f)));
};


This code assumes that you have the following already defined:
Code: Select all  Array.prototype.contains = function(el) {
    for (var i = 0; i < this.length; i++) {
      if (this == el) {
        return true;
      }
    }
    return false;
  };