0

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?

1 Answer 1

2
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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.