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

Problem with getFiles()

Engaged ,
Nov 12, 2013 Nov 12, 2013

Copy link to clipboard

Copied

I'm having a problem with getFiles()  - changing it from a user supplied path with selectDialog to a hard coded path. I know there are bug issues with early versions of CS and getFiles, but I can't see where I'm going wrong with:

// just get files

var sourceFolder = "C:\\temp\\json";

if (sourceFolder != null)

{

  var fileList = sourceFolder.getFiles();

}

Thank you.

TOPICS
Actions and scripting

Views

1.2K

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 , Nov 12, 2013 Nov 12, 2013

Yes you can use either forward or back slashes. That wasn't the reason for your problems with getFiles(). The problem is you were trying to use a folder method on a string object.

// just get files
var sourceFolder = "C:\\temp\\json";// this is a string object
if (sourceFolder != null)// it will never be null because it was just defined on th line above. Did you mean sourceFolder.exists?
{
  //var fileList = sourceFolder.getFiles();// strings do not have a getFiles method.

  var fileList = Folder(sou

...

Votes

Translate

Translate
Adobe
Advisor ,
Nov 12, 2013 Nov 12, 2013

Copy link to clipboard

Copied

Try

var sourceFolder = Folder("C:
temp
json");

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 ,
Nov 12, 2013 Nov 12, 2013

Copy link to clipboard

Copied

There are two ways to list a path, one as X shows, the other is using "/" and no colon.  It looks like your main issue is the double backslashes,

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
Engaged ,
Nov 12, 2013 Nov 12, 2013

Copy link to clipboard

Copied

var sourceFolder = Folder("C:

temp

json");

That just gets me: Error 4: Unterminated string constant.

ha ha! I've just seen what's gone on. The slashes have been turned into new lines by the web pixies. All appease the web pixies! Feed them sour milk, diet donuts and slashes! Ahem....

It should have read

var sourceFolder = Folder("C:/temp/json");

also works with back slashes

var sourceFolder = Folder("C:\\temp\\json"); // use back slashes

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 ,
Nov 12, 2013 Nov 12, 2013

Copy link to clipboard

Copied

LATEST

Yes you can use either forward or back slashes. That wasn't the reason for your problems with getFiles(). The problem is you were trying to use a folder method on a string object.

// just get files
var sourceFolder = "C:\\temp\\json";// this is a string object
if (sourceFolder != null)// it will never be null because it was just defined on th line above. Did you mean sourceFolder.exists?
{
  //var fileList = sourceFolder.getFiles();// strings do not have a getFiles method.

  var fileList = Folder(sourceFolder).getFiles();
}

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