USAGE:

                nextfile [type] [options] file
 
 PURPOSE:  
              Return the file name for a later date
              e.g. for G1_garb_YYMMDD-1s.mc
              Return it only if the file does exist
              (use -P to by-pass the existence test).

              For generating many files in a sequence, consider nextfiles

 TYPES:
 
  -GCF        Do for mc-files converted from gcf. Includes directory GYYYY.DOY
              This script can only be called from the dir-level above the mc-storage
              (yet, ../dir/file  will work from an mc-storage place)
              Examples:
 
     $ nextfile [-GCF] -a h1 /home/hgs/Seismo/gcf/G2015.036/GCF.2015:036:23:00:00.3U93ENZ2-10Hz.mc
     /home/hgs/Seismo/gcf/G2015.037/GCF.2015:037:00:00:00.3U93ENZ2-10Hz.mc

     $ cd ~/Seismo/gcf/G2015.042
     $ nextfile [-GCF] -a h24 ../G2015.042/GCF.2015:042:08:00:00.3U93ENZ2-10Hz.mc
     ../G2015.043/GCF.2015:043:08:00:00.3U93ENZ2-10Hz.mc
 
     $ cd ~/Seismo/gcf
     $ nextfile [-GCF] -a h24 G2015.042/GCF.2015:042:08:00:00.3U93ENZ2-10Hz.mc
     G2015.043/GCF.2015:043:08:00:00.3U93ENZ2-10Hz.mc
 
  -gcf      - Original gcf files, pwd should be above the file's directory

     $ nextfile -gcf -a h1 3u93z2/20110611_2300z.gcf
     3u93z2/20110612_0000.z.gcf
 
  -SAC <lead> - e.g.    <lead> = ST2.

     $ nextfile -SAC ST2. -a h1 10Hz/ST2.2013:10:31:08:00:00.WET-Z2-ACC-10Hz.ts
     10Hz/ST2.2013:10:31:09:00:00.WET-Z2-ACC-10Hz.ts
              is inofficial, molded after GCF
 
  -g d,l,"f-options
              General type of file names, when date substrings are contiguous.
              (File names with date parts spread out must get their own type
              definition.) 
              d - (string)  delimiter before date 
              l - (integer) length of date string
              "f-options" (words, blank-delimited) - format options for jdc

  -GWR        GWR files, processed under "general type" but tailored
              for the purpose.
              Delimiter = first two chars of the basename.
              Date substring length = 6 and f-options = "-D -fs -FS"
             
              Example:
 
     $ nextfile -g A1,6,"-D -fs -FS" -a 2 /home/hgs/TD/RAW_o054/A1121010.054.bz2
     /home/hgs/TD/RAW_o054/A1121012.054.bz2
     $ nextfile -GWR A1 -a 2 /home/hgs/TD/RAW_o054/A1121010.054.bz2
 
   -TD        This is also the default type; however, the gcf- and GCF-types are detected
              automatically on behalf of substring `GCF´ or `.gcf´, respectively, if no
              explicit type is given.
              In type TD, file name = [<dir/>]<abc>_<def>_YYMMDD<-ext>
              e.g. the G1_garb_YYMMDD-1s.mc files in ~/TD/d/
              Example:
 
     $ nextfile d/G1_garb_140201-1s.mc
     d/G1_garb_140202-1s.mc
 
 OPTIONS:
 
  -a advance    - expression for jdc's option -A
                  e.g.  -a h2  for two hours or  -a 1  for one day.
                  Type Defaults
                  -TD    1  (one day)
                  -GWR   1
                  -g     1 
                  -gcf   h1 (one hour)
 
  -x ext        - file name extension. Defaults:
                  type -GCF : the last substring with regexp `\..*\..*'
                  type  -TD : auto detected, everything from the last `-'
                  type   -g : auto detected, everything after the time string

  -P            - return the file name even if the file does not exist.

 EXAMPLES:
   $ nextfile -g SG.OSO.HGE.,10,"-D -:::" ~/Seismo/mseed/SG.OSO/d/SG.OSO.HGE.2018:10:18-1s.ts
   /home/hgs/Seismo/mseed/SG.OSO/d/SG.OSO.HGE.2018:10:19-1s.ts
  
   Complicated? Try instead:
   $ next-mseed -k0
~/Seismo/mseed/SG.OSO/d/SG.OSO.HGE.2018:10:18-1s.ts
   /home/hgs/Seismo/mseed/SG.OSO/d/SG.OSO.HGE.2018:10:19-1s.ts


 ADVANCED EXAMPLES:
 
   $ nextfile -x .WET-Z2.ts -g ST2.,19,"-D -::: -k3" -a h1 \
   ? ~/TD/Wettzell/ST2.2013:10:27:02:00:00.WET-Z2.ts
   /home/hgs/TD/Wettzell/ST2.2013:10:27:01:00:00.WET-Z2.ts

   Why?
   -x : the suffix after the time string is `.WET-Z2.ts´
        (redundant if the suffix abuts the time string)
   -g : the prefix is `ST2.´
        (the file path is automatically copied),
        the width of the time string is 19 chars,
        ST2.2013:10:27:02:00:00.WET-Z2.ts
            1234567890123456789
        and jdc -D -::: -k3 <date-string>
   -a : increment 1 hour
 _______________________________________________________________________
 
   $ set files = ( G2015.036/GCF.2015:036:23:00:00.3U93ENZ2-10Hz.mc )
   $ foreach i ( `fromto 1 5` )
   >   set files = ( $files `nextfile -gcf -a h1 $files[$#files]` )
   > end
   $ tslist-app -O:`label SV,Z` d/tmp.mc -I + $files

   $ set f=G2011.166/GCF.2011:166:00:00:00.3U93Z2.ts
   $ tslist-app -O:`label SV,Z` d/tmp.mc -I [++ late options] \
   ?            + $f `nextfile -a h1 $f` `nextfile -a h2 $f`
 _______________________________________________________________________

   With super-script nextfiles:
  
   $ set f=G2015.036/GCF.2015:036:23:00:00.3U93ENZ2-10Hz.mc
   $ tslist-app -O:`label SV,Z` d/tmp.mc -I + `nextfiles I 3 $f [-gcf -a h1]`
   
         [...] is redundant, since `-gcf' is auto-detected and `-a h1' the default 



 USAGE
           nextfiles [I] #n first-file [options]
 
 PURPOSE: 

           Calls nextfile to build up an array of filenames,
           which it returns, nonexistent files not withstanding.
 
           With I the first file will be included, else only the later files are returned.
           i I +i +I are synonymous.
 
           The file type -g will probably not get the option handed over to nextfile correctly.
           This, however, will work:

           $ nextfiles 3 /home/hgs/TD/RAW_o054/A1121010.054.bz2 -g A1,6,"-D -fs -FS" -a 1

           (the -g option appears first, the -a option (compulsory!) and any other option to nextfile
           appear at the end)
 
           Simpler:
           $ nextfiles 3 /home/hgs/TD/RAW_o054/A1121010.054.bz2 -GWR

.bye