home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / software / temacd / godfather / TGF_069.exe / $INSTDIR / Scripts / Advanced.scu < prev    next >
Encoding:
Text File  |  2005-02-06  |  2.2 KB  |  66 lines

  1. {!%A:1|%A|%Y - %L|%G}
  2. // the first line contains the folder structure and is dynamically used upon script execution, it is optional
  3.  
  4. {
  5.   sample script to force special folder rules
  6.   the folder structure defined is the following :
  7.   %A , 1   - artist first letter
  8.   %A       - artist
  9.   %Y - %L  - year album
  10.   %G       - dummy genre level, The %G variable is only used as an example of how to check for other values
  11. }
  12. program Advanced_folder_rules;
  13.  
  14. const
  15.   _MiscFolder = '0-9 & Misc'; // mine is '0-9 & Misc'
  16.  
  17. var
  18.   sTmp: string;
  19. begin
  20.  
  21.   // phase 1 loop trough entries and adjust values as needed
  22.   re_Init( false );
  23.   repeat
  24.      sTmp := re_getLevel( 2 );
  25.      if UpperCase( Copy( sTmp, 1, 4 ) ) = 'THE ' then begin // remove 'the'
  26.         re_setLevel( 1, Copy( sTmp, 5, 1 ) );
  27.         re_setLevel( 2, Copy( sTmp, 5, 9999 ) );
  28.      end;
  29.  
  30.      if Pos( Copy( sTmp, 1, 1 ), '1234567890.''' ) > 0 then begin // move all those artists to custom folder
  31.         re_setLevel( 1, _MiscFolder );
  32.      end;
  33.  
  34.      sTmp := re_getLevel( 4 );
  35.      if UpperCase( sTmp ) = 'SOUNDTRACK' then begin // special genre
  36.         re_setLevel( 1, _MiscFolder );
  37.         re_setLevel( 2, 'Soundtracks' );
  38.      end;
  39.      re_removeLevel( 4 ); // remove the level, it used only to check genre
  40.  
  41.      sTmp := Trim( re_getLevel( 3 ) );
  42.      if sTmp = '-' then begin // missing year AND album tags
  43.         re_removeLevel( 3 );
  44.      end;
  45.   until not re_Skip;
  46.  
  47.   // we have to do the count of files per folder here because the structure may have been altered above
  48.   // phase 2 get count and loop trough entries and remove level if we must
  49.   re_Init( true );
  50.   repeat
  51.      if re_getCount = 1 then begin // no year - album structure for just one song
  52.         re_removeLevel( 3 ); // if level 3 was removed before it will not do anything
  53.      end;
  54.   until not re_Skip;
  55.  
  56.   // we have to do the re-count of files per folder here because the structure may have been altered above
  57.   // phase 3 get count and loop trough entries and remove level if we must
  58.   re_Init( true );
  59.   repeat
  60.      if re_getCount = 1 then begin // no Artist folder for just one song put it in the root letter folder ( A B C ... )
  61.         re_removeLevel( 2 );
  62.      end;
  63.   until not re_Skip;
  64.  
  65. end.
  66.