Search for files
1. findFiles path:="C:\c" ext:= "doc"
2. findFiles path:="C:\c" time:= "010203-"
3. findFiles path:=System.path.Ascii$ from:=2456658 to:=2456665
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
path to look for files | path |
Input string |
|
input full path to look for files |
Recursive | recursive |
Input int |
|
Specify whether to find the files in the recursive folders |
filename or extension | ext |
Input string |
|
input filename or extension to be finded |
file size range | size |
Input string |
|
input file size range to be found |
file modified date time range | time |
Input string |
|
input file modified date time range to be found |
modified date start | from |
Input double |
input the beginning of a date time range so only file(s) modified during this period will be found. | |
modified date end | to |
Input double |
input the ending of a date time range so only file(s) modified during this period will be found | |
get result file names with full path | addpath |
Input int |
|
get result file names with full path or not |
result file names separated by CRLF | fname |
Output string |
|
output result file names separated by CRLF |
This X-Function is used to search file in specific path and conditions.
string struff$=%Y; Dbegin=date(09/01/2016); Dend=date(12/31/2016); findFiles path:=struff$ ext:="ini" from:=Dbegin to:=Dend addpath:=0; int nn = fname.GetNumTokens(CRLF); type "following files were changed between $(Dbegin, D0) - $(Dend, D0)"; for(int ii = 1; ii <= nn; ii++) { string strFilename$ = fname.GetToken(ii, CRLF)$; type strfilename$; }
doc -s; doc -n; string fname$;//all the XF that deals with files default to fname$ string //Find files and import them findFiles path:=system.path.program$+"Samples\Curve Fitting" ext:="*.dat" addpath:=1;//result in fname$ //import from fname$, ImpMode=3 for new book impasc option.sparklines:=0 option.ImpMode:=3 Options.Names.FNameToBk:=0; //Create graphs with only the 1st 2 columns doc -e W { plotxy iy:=(1,2) plot:=200; window -ia; } dlgSave ext:=*.avi title:="Saving Video file location"; //Make video int err = vw.Create(%(fname$)); if(err!= 0) { err=; break 1; } doc -e P { vw.WriteGraph(%H,1) } vw.Release(); type -a "File saved to %(fname$)";
//Code to get all files from User Files path //and count each file types by extension string uffPath$ = system.path.ini$; type -a "The following type of files are found in the User Files folder"; type uffPath$; string results$; findFiles path:=uffPath$ recursive:=1 fname:=results$; int nn = results.GetNumTokens(CRLF); type "A Total of $(nn) files found"; // add each new type into array StringArray sa; // fill a temp dataset with 100 cells of1, as first adding will count as 1 dataset na=data(1,1,100);// array to keep count for(int ii = 1; ii <= nn; ii++) { string strFilename$ = results.GetToken(ii, CRLF)$; string strExt$ = strFilename.GetFileExt()$; int nPos = sa.Find(strExt$); if(nPos < 1) // not found sa.Add(strExt$); else { na[nPos] += 1; type -q "$(ii): $(nPos) --> $(na[nPos])"; } } // now print the results in the StringArray sa and numeric array na for(int ii = 1; ii <= sa.GetSize(); ii++) { string strExt$ = sa.GetAt(ii)$; type "$(ii): %(strExt$) $(na[ii])"; }
Keywords:subfolder, recursive, date, time, extension