Opening file using Wildcards

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Raymondo
Posts: 3
Joined: 11 Jun 2012 04:15

Opening file using Wildcards

#1 Post by Raymondo » 03 Aug 2012 04:31

batch file wildcards i have to open a file but there are two very similar ones and i only open one.

say i have two documents that are the same like
This_is_a_test_v10.02.03.00.txt
This_is_a_test_v10.02.03.00_hello.txt

i only want to open the top one and not the bottom one.

this is what i have so far

Code: Select all

For /f "usebackq tokens=*" %%I in (`dir /b /a-d "%filepath%\This_is_a_test*.txt"`) do start notepad "%filepath%\%%I"


Thank you

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Opening file using Wildcards

#2 Post by foxidrive » 03 Aug 2012 06:07

Code: Select all

@echo off
pushd "%filepath%"
For /f "delims=" %%a in ('dir /b /a-d "This_is_a_test*.txt"') do (
start "" notepad "%%a"
goto :next
)
:next
popd

Raymondo
Posts: 3
Joined: 11 Jun 2012 04:15

Re: Opening file using Wildcards

#3 Post by Raymondo » 03 Aug 2012 07:00

Awesome thanks that is perfect

Post Reply