home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,226 of 68,980   
   JJ to conneljl@bc.edu   
   Re: Find a file name based on a variable   
   18 May 18 22:38:08   
   
   From: jj4public@vfemail.net   
      
   On Thu, 17 May 2018 07:39:17 -0700 (PDT), conneljl@bc.edu wrote:   
   > Is there a way (and what does it look like) to find a file in a specified   
   folder that contains a variable the user enters?   
   >   
   > something along the lines of   
   >   
   > set /p V1=Please enter the unit number you want to find the file for as a   
   two digit number (02, 23, etc)   
   > echo   
   > echo   
   > if not exist "%V1%*" echo No Order File Found!!!!   
   > @timeout /t 2 /nobreak >nul   
   > if not exist "%V1%*" goto END   
   > Schtaskst /Run blah blah blah   
   >:END   
      
   That IF command's condition is already able to check the presence if the   
   file whose part of the file mask is specified by a variable.   
      
   If you want to retrieve the file name(s), you can use FOR command. e.g.   
   below code displays all matching file names.   
      
   set /p "V1=Enter start of file name: "   
   for %A in ("%V1%*") do echo Found file: %A   
      
   When in a batch file the "%" character must be specified twice. e.g.   
      
   [code]   
   @echo off   
   set /p "V1=Enter start of file name: "   
   for %%A in ("%V1%*") do echo Found file: %%A   
   [/code]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca