Folder object to string question

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
ndeboar
Posts: 8
Joined: April 17th, 2005, 8:39 pm

Hey Guys,

Another quick question.

Im still working on a script to grab all my renders and shove them in a comp. Im using the file names to dertermine the layer order in the comp (eg character_L1_v01.tif, the L dertemines its order), so im trying to do some basic string functions.

var folders = theFolder.getFiles(); // get an array of the folders in the dir
var myString = (folders[1]); // grab the name of the first one
var x = myString.length;// get the length of characters in the name

All this does is grab the name of the folder in spesified directory, and the all i want to get is the length of the string name of the folder so i can run a loop to check each character for the information i want.

Q: I can't seem to use string.length function with folder objects?! Can i convert a folder object to a string?

Cheers,

Nick Deboar
/Digital Director/
*The People's Republic of Animation
http://www.thepra.com.au
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

At the moment, you're trying to get the length property of the actual folder object (it doesn't have a "length" property); what you really want is to get the length property of the name, path, or absoluteURI of the folder object.

alert(folders[0].absoluteURI.length)

And you might have missed that JavaScript is zero-based, so the first object in this case will be at 0!


Cheers,
Dave
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

Additionally, you may want to try using some of the built-in string scanning (e.g. indexOf() or split()) or regular expression functions rather than looping through the characters in a string. The implementation of the built-in functions are likely more efficient and easier to use.

Peter
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

Abso-lutely!
Post Reply