long FileFindFirst( const stringfile_filter, // String – search filter string&returned_filename, // Name of the file or subdirectory found intcommon_flag=0// Defines the search );
//— display the window of input parameters when launching the script #property script_show_inputs //— filter inputstring InpFilter=”Dir1\\*”; //+——————————————————————+ //| Script program start function | //+——————————————————————+ voidOnStart() { string file_name; string int_dir=””; int i=1,pos=0,last_pos=-1; //— search for the last backslash while(!IsStopped()) { pos=StringFind(InpFilter,”\\”,pos+1); if(pos>=0) last_pos=pos; else break; } //— the filter contains the folder name if(last_pos>=0) int_dir=StringSubstr(InpFilter,0,last_pos+1); //— get the search handle in the root of the local folder long search_handle=FileFindFirst(InpFilter,file_name); //— check if the FileFindFirst() is executed successfully if(search_handle!=INVALID_HANDLE) { //— in a loop, check if the passed strings are the names of files or directories do { ResetLastError(); //— if it’s a file, the function returns true, and if it’s a directory, it returns error ERR_FILE_IS_DIRECTORY FileIsExist(int_dir+file_name); PrintFormat(“%d : %s name = %s”,i,GetLastError()==ERR_FILE_IS_DIRECTORY ? “Directory” : “File”,file_name); i++; } while(FileFindNext(search_handle,file_name)); //— close the search handle FileFindClose(search_handle); } else Print(“Files not found!”); }