home *** CD-ROM | disk | FTP | other *** search
- # QTAwk utility to split input lines into DOS path and filename.ext
- #
- BEGIN {
- # characters excluded from filename
- # all other characters are valid filename characters for DOS
- exc_c = /[!\x01-\x21."\/\\\[\]:|<>+=;,]/;
- # DOS filename.ext pattern
- # filename consists of all characters not excluded from proper name
- # followed by optional extension of 1 to 3 characters
- # followed by end of string
- name_pat = /{exc_c}+(\.{exc_c}{1,3})?$/;
- }
-
- # split each line into "path" and "filename"
- # strategy: delete "filename.ext" from end using regular expression
- # to recognize and "sub" function to replace with zero length string.
- # use "substr" function to then get suffix of path, which is the
- # filename.ext. This strategy works even if filename.ext is not present.
- #
- {
- # everything into path
- path = $0;
- # delete filename.ext at end to leave path
- sub(name_pat,"",path);
- # get suffix of path, which is filename.ext
- filename = substr($0,1 + length(path));
-
- print path;
- print filename;
- }
-