Reputation: 3
I'm trying to search for a file that ends with *.ac and open that file in a program. There will always just be one file with this extension. The directory where the bat file will search is always the directory where it's running from.
Currently this works:
@echo off
for /r "%CD%" %%a in (*) do if "%%~nxa"=="myFileName.ac" set p=%%~dpnxa
start /d "C:\Program Files (86)\CaseWare\" cwin32.exe "%p%"
But the myFileName.ac will always have a different name.
I tried to change it to *.ac but then it doesn't work :(
@echo off
for /r "%CD%" %%a in (*) do if "%%~nxa"=="*.ac" set p=%%~dpnxa
start /d "C:\Program Files (86)\CaseWare\" cwin32.exe "%p%"
Any help please?
Upvotes: 0
Views: 1586
Reputation: 80023
for /r "%CD%" %%a in (*.ac) do set p=%%~dpnxa
should find that elusive file.
@echo off
for /r "%CD%" %%a in (*.ac) do start /d "C:\Program Files (86)\CaseWare\" cwin32.exe "%%~dpnxa"
should process it.
Upvotes: 2