Dear All
I have a number of files. Name of these files consist "Area name" and "Book No" like 123401: in this 1234 is the name of area and 01 is Book No. I want to design a batch file which gets a string (Area Name) form user and find that book from a specific folder.
Urgent help is required.
Thanks a lot in advance.
search a file(s) name having specific string
Moderator: DosItHelp
Re: search a file(s) name having specific string
I'm unsure qhat you are looking for:
What do you mean with "find that book from a specific folder"?
Unless you haven't forgotten to mention something, once you have the "Area name" and "Book No" you won't need to search for the file in your "specific folder" (in EBNF notation):
"<specific_folder>\<Area name><Book No>".
Maybe i'm wrong, but this task sounds like a homework for school, or something similar:
You might use "set /P" to read user input into a variable;
type "help set" into the command shell ("cmd.exe") for further information.
What do you have so far, and which is the part you need help with?
penpen
What do you mean with "find that book from a specific folder"?
Unless you haven't forgotten to mention something, once you have the "Area name" and "Book No" you won't need to search for the file in your "specific folder" (in EBNF notation):
"<specific_folder>\<Area name><Book No>".
Maybe i'm wrong, but this task sounds like a homework for school, or something similar:
You might use "set /P" to read user input into a variable;
type "help set" into the command shell ("cmd.exe") for further information.
What do you have so far, and which is the part you need help with?
penpen
Re: search a file(s) name having specific string
Thanks penpen for taking interest.
Actually we have a lot of files every month on a ftp server. These files have data about meter reading of customers. Programmers had designed tables without "Area" & "Book" fields. So these files contain data without area name and book no. I have to design an inquiry program which collects data from these files. Now If user want to display the data of a particular file: means for book 01 of area 1234: I have to search that file in the collection or folder and then process the data of that file.
I hope now you can understand the situation.
Actually we have a lot of files every month on a ftp server. These files have data about meter reading of customers. Programmers had designed tables without "Area" & "Book" fields. So these files contain data without area name and book no. I have to design an inquiry program which collects data from these files. Now If user want to display the data of a particular file: means for book 01 of area 1234: I have to search that file in the collection or folder and then process the data of that file.
I hope now you can understand the situation.
Re: search a file(s) name having specific string
If i've understand right, then you have stored all files in a database directory (lets assume it is "D:\"),
so your directory structure containing all "books" is something like that:
If you are searching for Book No 02 in Area 1234, then your file's location is "D:\123402".
A batch file ("book.bat") echoing the full path to the book (without any validity check) then is:
You may use the above batch, by calling "book.bat", setting the first parameter to the needed AreaName and the second parameter to the needed Book no:
So i still think i miss something.
penpen
so your directory structure containing all "books" is something like that:
Code: Select all
D:\
+---123401
+---123402
...
+---567801
If you are searching for Book No 02 in Area 1234, then your file's location is "D:\123402".
A batch file ("book.bat") echoing the full path to the book (without any validity check) then is:
Code: Select all
@echo("D:\%~1%~2"
You may use the above batch, by calling "book.bat", setting the first parameter to the needed AreaName and the second parameter to the needed Book no:
Code: Select all
@echo off
call book.bat "1234" "01"
So i still think i miss something.
penpen
Re: search a file(s) name having specific string
wasimsono wrote:Thanks penpen for taking interest.
Actually we have a lot of files every month on a ftp server. These files have data about meter reading of customers. Programmers had designed tables without "Area" & "Book" fields. So these files contain data without area name and book no. I have to design an inquiry program which collects data from these files. Now If user want to display the data of a particular file: means for book 01 of area 1234: I have to search that file in the collection or folder and then process the data of that file.
I hope now you can understand the situation.
@echo off
rem SM_MAXCADASTRO_17_01_005.ZIP
set servidor=%USERPROFILE%\Desktop\batch\arquivos
set modulo=SM_MAXCADASTRO
set versao1=17
set versao2=01
set versao3=000
set extensao=zip
set existe=
call:verifica %servidor%, %modulo%, %versao1%, %versao2%, %versao3%, %extensao%
echo %existe%
echo.&pause&goto:eof
:verifica
if exist %~1\%~2_%~3_%~4_%~5.%~6 (
set existe=1
) else (
set existe=0
)
goto:eof
Re: search a file(s) name having specific string
@OP
Did you mean search a file having specfic string in the name or in their contents
It's unclear until now for me
Did you mean search a file having specfic string in the name or in their contents
It's unclear until now for me