1.

Solve : How to extract file name in folder based on extension?

Answer»

I would like to extract the file name of a file with a certain EXTENSION in the current folder.

The extension is ".LGR", it's just a text file.

Is there a simple WAY to place this file name into a variable?
Thanks a lotThis ASSUMES there is only one file in the default directory which has the extension .lgr

Code: [Select]@echo off
cls
setlocal

for /f "delims=*" %%1 in ('dir /b *.lgr') do (
set variable=%%~n1
)

Yes, I only have one file with that extension.
Your code works great.
Thank you very muchThanks for coming back to REPORT your success.

Good luck.



Discussion

No Comment Found