|
|
|||||||
Hi The path to the file is always the same but the filename can vary. Example:Path is always "H:\foldername\" and the filename is FILExx.cmd (where xx is random) I want to run this file if it exist. IF EXIST("H:\foldername\FILE*.cmd") ;Works ok RUN "H:\foldername\FILE*.cmd" ;Can't run a file with an asterix (*) in the path ENDIF So how can I determine what the hole filename is? |
||||||||
|
|
|||||||
The DriPlus() UDF might be an option. DirPlus() - a recursive dir tool |
||||||||
|
|
|||||||
Thanks, but the UDF was very long (advanced) for this. Later i found the UDF DIRLIST() and I modified that one a little. IF EXIST("H:\foldername\FILE*.cmd") DIRLIST("H:\foldername\FILE*.cmd") SHELL "H:\foldername\" + $searchedfile ENDIF FUNCTION DIRLIST($directoryname) DIM $filename, $counter DIM $filelist[1] $counter=1 $filename=DIR($directoryname) WHILE $filename<>"" AND @ERROR=0 REDIM PRESERVE $filelist[$counter] $searchedfile = $filename $filelist[($counter-1)]=$filename $counter=$counter+1 $filename=DIR("") LOOP ENDFUNCTION |
||||||||
|
|
|||||||
Too advanced or too long? Bryce did the job. You just have to know what you put in and what it returns. Do not forget to add the DirPlus() UDF Code: If NOT @LOGONMODE Break On Else Break Off EndIf Dim $RC $RC = SetOption("Explicit", "On") $RC = SetOption("NoMacrosInStrings", "On") $RC = SetOption("NoVarsInStrings", "On") $RC = SetOption("WrapAtEOL", "On") Dim $Path, $Directory, $Item $Path = "H:\foldername\" $Directory = DirPlus($Path) For Each $Item in $Directory If InStr($Item, $Path + "File") AND Right($Item,3) = "CMD" ; Do stuff here EndIf Next |
||||||||
|
|
|||||||
well.... DIRPlus() is the Swiss Army knife of directory UDF's $Directory = DirPlus($Path,'/a-d /f cmd /m file') will only return a list of "*.cmd" files that have the word "file" in them. |