Find and open file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ToNovy
Posts: 1
Joined: 21 Sep 2011 04:12

Find and open file

#1 Post by ToNovy » 21 Sep 2011 06:46

Hi all,

I'm looking for someone who can help me resolve this:

I have DB folder structure for technical documents looks like for example:

122-redukce-nastavce
├ 0-99
│ ├ 6-122-00002 NÁSTAVEC Mo1 na Mo1-14x250 -PL
│ ├ 6-122-00006-Mo1xMo1;L=250
│ ├ 6-122-00010-Mo3xMo2;L=300
│ etc.
├ 100-199
├ 200-299
etc.
124-rychloupinaci hlavice
126-vrtaci a vyvrtavaci tyce pevne
etc.

So I need script which can find and open file 6-122-00002-00.dwg if user input groupe = 122 and number = 2
I know how convert 122 and 2 to full name 6-122-0002-00.dwg but I can't figure out, how find full path to folder.

Tnx for any advice

rodrigolima
Posts: 21
Joined: 19 Jul 2013 11:35
Location: Brazil

Re: Find and open file

#2 Post by rodrigolima » 27 Nov 2013 11:13

Hello ToNovy

try it:

Code: Select all

@echo off
cls

if exist pipeline.txt del pipeline.txt

set /p input1=Enter Folder Number:

If [%input1%]==[] (
echo Empty Folder Number
pause
goto eof
)

set /p input2=Enter Document Number:

If [%input2%]==[] (
echo Empty Document Number
pause
goto eof
)

:: Change file extension to dwg
dir "6-%input1%-*%input2%*.txt" /b/s/n > pipeline.txt 2>NUL

IF ERRORLEVEL 1 (
   if exist pipeline.txt del pipeline.txt
   @echo Lecture: 6-%input1%-*%input2%*.dwg not found.
   PING 1.1.1.1 -n 1 -w 1000 >NUL
   goto eof
)

echo Press any Key to open lecture 6-%input1%-*%input2%*.dwg
pause >nul
set /p file=<pipeline.txt

if exist pipeline.txt del pipeline.txt
start notepad %file%
goto eof

:eof
goto:eof


Your Folder Structure

122-redukce-nastavce
├ 0-99
│ ├ 6-122-00002 NÁSTAVEC Mo1 na Mo1-14x250 -PL
│ ├ 6-122-00006-Mo1xMo1;L=250
│ ├ 6-122-00010-Mo3xMo2;L=300
│ etc.
├ 100-199
├ 200-299
etc.
124-rychloupinaci hlavice
126-vrtaci a vyvrtavaci tyce pevne
BatchFile.bat

I hope that it be useful for you.

See you

Post Reply