View Full Version : Length Of File Sequence


ruchitinfushion
06 June 2011, 04:51 AM
Hi,Anybody know how to find length of file sequence in selected folder??

string $FileList[] = `getFileList -folder $ImageDirectory -filespec ".tga"`;
Here size($FileList) will be total number of targa file in selected folder

But how to find length of sequence only,not every file with same extension??
Reply ASAP.Thank you.

berniebernie
06 June 2011, 10:23 AM
filter files in the array the same prefix "fileSequenceName####". It'll take a little time, but that's all I can think of with mel.

artbycrunk
06 June 2011, 09:59 PM
hi ruchit,

here is a script i came up with for the solution, it will popup a window for file selection, once a file is selected it will check for the sequence based on the selected file and extension.
It works on sequence seperated by dot and underscore, made it as smart as i could in the given time.

It will output final information to the script editor.

the script can still be heavily improved, currently its 3:23 in the morning so my brain is working slow...

let me know, what your actually trying to make, and if the script was of any help.. :)



/* *******************************
*******************************

Script Name: Analyze File Sequence 0.5

Created On June 28th 2011
Authored By - Crunk AKA Savio Fernandes

//UPDATES//


*******************************
******************************* */

global proc crAFileSequence() {

fileBrowserDialog -m 0 -fc ("FilePath_Dir") -ft "image" -an ("Browse Script Path ") -om "Reference";

}

global proc int FilePath_Dir( string $filename, string $fileType )
{
string $selArray[], $selArray2[];
string $FileList[];

//Final Dirname Name.
string $dirname = dirname( $filename );
print "\n";
int $size_dirname = `size $dirname`+2;
int $size_filename = `size $filename`;
string $part_filename_full = `substring $filename $size_dirname ($size_filename)`;

//Final Filename Name.
string $part_filename = `substring $filename $size_dirname ($size_filename-4)`;
int $size_part_filename_full = `size $part_filename_full`;
int $size_part_filename = `size $part_filename`+2;

//Final Extension Name.
string $ext = `substring $part_filename_full ($size_part_filename) ($size_part_filename_full)`;

//Get File List Based on Directory and Extension.
string $ext_FileList[] = `getFileList -folder ($dirname+"/") -filespec ("*."+$ext)`;

clear $FileList;

for ($files2 in $ext_FileList)
{
//Remove Extension Again.
int $size_files = `size $files2`;
string $files = `substring $files2 1 ($size_files-4)`;

//Check if sequence is . separated.
if (`gmatch $files "*.[0-9]*"`)
{
tokenize $files "." $selArray;
tokenize $part_filename "." $selArray2;

if(size($selArray) == size($selArray2)) //Error Checking
{
//Filter Filename with selected Filename.
if($selArray[0] == $selArray2[0])
{ $FileList[size($FileList)] = $files+"."+$ext; }
}
}

//Check if sequence is _ separated.
else if(`gmatch $files "*_[0-9]*"`)
{
tokenize $files "_" $selArray;
tokenize $part_filename "_" $selArray2;

if(size($selArray) == size($selArray2)) //Error Checking
{
//Filter Filename with selected Filename.
if($selArray[0] == $selArray2[0])
{ $FileList[size($FileList)] = $files+"_"+$ext; }
}
}

}
print ("There are "+size($FileList)+" files in selected sequence\n");
print $FileList;

return 1;
}

crAFileSequence();

ruchitinfushion
06 June 2011, 09:55 AM
Oh This is working like charm,Thanx much Savio

CGTalk Moderation
06 June 2011, 09:55 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.


1