// EnumerateDirectoryTree // // last modified 10-Sept-2002 RTH // // Prompts for a starting directory then iteratively lists the contents of // this folder and its sub-folders. This script could be modified for example // to carry out an action on every image found in a directory tree. // // number indent = 0 void OutputIndent( void ) { number i for( i = 0; i < indent; i++ ) Result( " " ) } void EnumerateDirectory( string path ) { indent += 2 TagGroup files = GetFilesInDirectory( path, 3 ) number num_files = files.TagGroupCountTags() number i_t; for( i_t = 0; i_t < num_files; ++i_t ) { TagGroup tg; if ( files.TagGroupGetIndexedTagAsTagGroup( i_t, tg ) ) { string file_name; if ( tg.TagGroupGetTagAsString( "Name", file_name ) ) { OutputIndent() Result( file_name + "\n" ) string complete_path = PathConcatenate( path, file_name ) if( DoesDirectoryExist( complete_path ) ) { EnumerateDirectory( complete_path ) } else { // ProcessFileHere( complete_path + "\n" ) } } } } indent -= 2 } string path if( ! GetDirectoryDialog( path ) ) exit(0) EnumerateDirectory( path )