Help with find and start script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bane64
Posts: 2
Joined: 21 Oct 2008 23:05

Help with find and start script

#1 Post by bane64 » 21 Oct 2008 23:24

Hey everyone new here just started with batch's and what not. Been searching for a while but cant find it anywhere, don't know if its possible.

Alright, I want to make a batch file that when run will search for a file then start it and is set up so that it
-will ask the user for the path, which in my case i will just want a directory so i assume -s will have to be in the code
-then ask for the user for search information. I want it to be able to take in 2 inputs for one file, so lets say the file name is FILE_NAME_01.xxx and another would be FILE_BLANK_02.xxx, and the user wanted the first one he/she could enter "FILE" and "01" so if you dont know complete file name. I tried wildcards but didnt seem to want to work.
3. Then when found would ask if it is the right file if so start the file if not retry the search with different query.

Ive written a small one that only works if I put in the full path and can only accept one input and then to start that file i have to copy the full path and enter. So it doesnt save me any time, I could almost use explorer that quickly.

Thanks in advance

bane64
Posts: 2
Joined: 21 Oct 2008 23:05

Solution

#2 Post by bane64 » 27 Oct 2008 22:50

Been working on it even though I didnt get any replies. I was unable to solve this in standard cmd/command. I downloaded a replacement called 4nt and then wrote a rough script, but does what I want.


Code: Select all

@echo off
title Search
del tempfile.dat
cls

:start
cls
input Enter Directory(s): %%dir
echo Enter Parameter 1:
input %%srch1
echo Enter Parameter 2:
input %%srch2
cls

echo Now Looking in Drive(s):: %dir  For:: %srch1 / %srch2
echo Found::

ffind /s /b /l /d%dir "*%srch1*%srch2*" >> tempfile.dat
type /l tempfile.dat

inkey Correct file(s)?(y/n): %%ans1
if %ans1 == n goto retry
if %ans1 ==N goto retry

inkey Which file would you like to run?: %%ans2

SET lin=%@EVAL[%ans2 - 1]

SET file=%@LINE[tempfile.dat,%lin]
start %file
DEL tempfile.dat
cls
pause
goto start

:retry
cls
DEL tempfile.dat
cls
Echo Try Search again!
pause
cls
goto start


pause


What the code does is search for a file by 2 parameters, if you want/need only one just enter * as the second, in the drive you enter. it then copies all the paths into the tempfile.dat, then reads that file and labels a # to each path. then you enter the corresponding # to your file and it loads. deletes the tempfile when needed.

Works pretty well, though its in a third party shell. So if anyone was looking for something like this here it is.

And if anyone can get something like this scripted for cmd/command that would be awesome.

Post Reply