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

Filter "alias" Files

Advocate ,
Oct 19, 2013 Oct 19, 2013

Copy link to clipboard

Copied

Hello fellow developers,

is there a way to discern whether a File is an alias on Mac? Like:

var fList = Folder("~/Desktop/TEMP").getFiles();

$.writeln(fList.toSource());

// [new File ("~/Desktop/TEMP/.DS_Store"), new File ("~/Desktop/TEMP/_Anita.jpg"), new File ("~/Desktop/TEMP/Anita.jpg")]

The TEMP folder contains (besides the hidden .DS_Store) a proper jpg called Anita.jpg and an alias which is _Anita.jpg.

On PC they have a .lnk extension, on Mac it gets harder to recognize them.

I thought to filter the getFile with somethig such as:

var fList = Folder("~/Desktop/TEMP").getFiles( function(f) {

          //... if f is alias then return false

          return true

});

Bu I don't know how to fill the function.

Any idea?

Thank you!

Davide Barranca

www.davidebarranca.com

TOPICS
Actions and scripting

Views

902

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

Guru , Oct 19, 2013 Oct 19, 2013

There is a File property for that. File.alias will be true if the file is an alias or shortcut.

Or are you saying that property doesn't work on Mac?

Votes

Translate

Translate
Adobe
Guru ,
Oct 19, 2013 Oct 19, 2013

Copy link to clipboard

Copied

There is a File property for that. File.alias will be true if the file is an alias or shortcut.

Or are you saying that property doesn't work on Mac?

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
Advocate ,
Oct 19, 2013 Oct 19, 2013

Copy link to clipboard

Copied

Yup Mike,

I did completely miss that property!

Works flawlessly, thanks!

var fList = Folder("~/Desktop/TEMP").getFiles( function(f) {

          if (f.alias) { return false; }

          return true;

});

Davide

www.davidebarranca.com

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
Guru ,
Oct 19, 2013 Oct 19, 2013

Copy link to clipboard

Copied

You could also do something like this.

var fList = Folder("~/Desktop/TEMP").getFiles( function(f) {
          return !f.alias;
});

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
Advocate ,
Oct 19, 2013 Oct 19, 2013

Copy link to clipboard

Copied

Speaking of aliases, do you happen to know how to copy them around "as aliases"?

Like:

var sourceFolder = Folder("~/Desktop/TEMP/Source");

var destFolder = Folder("~/Desktop/TEMP/Destination");

var fList = sourceFolder.getFiles();

for (var i = 0, len = fList.length; i < len; i++) {

  fList.copy(destFolder + "/" + fList.name);

}

This one works, but copies the referenced files (instead of the aliases themselves)

Davide

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
Community Expert ,
Oct 20, 2013 Oct 20, 2013

Copy link to clipboard

Copied

LATEST

you can recreate the alias

var sourceFolder = Folder("~/Desktop/TEMP/Source");

var destFolder = Folder("~/Desktop/TEMP/Destination");

var fList = sourceFolder.getFiles();

for (var i = 0, len = fList.length; i < len; i++) {

  //fList.copy(destFolder + "/" + fList.name);

  if (fList.alias) {

      var destFile = new File(destFolder + "/" + fList.name);

      destFile.createAlias (fList.fsName);

  }

}

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