SETSUBSTR Find number of substrings in string |
Top Previous Next |
This script command searches [ string ] for occurences of [ substr ] and saves the number of occurences found in [ variable ].
The following example uses SETSUBSTR to determine if a filename has no extension:
SET filename = "MyData" SETSUBSTR dots = filename "." IFNUM= dots 0 GOTO no_extension
The following example finds the number of file name segments:
SET filename = "data.temporary.sbc.xml" ;; find how many "." occur SETSUBSTR dots = filename "." ;; the number of segments is one more than the number of dots SETNUM segments = dots + 1
The SETSUBSTR command can be used to detect and remove unwanted characters (see: Rename files during download) from the names of files to be downloaded. The SETEXTRACT and SETRIGHT commands are also useful for parsing a filenames.
Related command(s): SETEXTRACT, IFSUBSTR, SET, SETRIGHT, SETLEFT, SETLEN, SETMID, SETREPLACE |