I want to iterate all files of my folder based on their file extension, and file names using a batch script.
I have the below code to get the file extension, and can echo it with %%~xa
, but when I try to define it as file_extension
, the output just returns as ECHO is off.
Can someone please tell me how to do it?
@echo off
setlocal EnableDelayedExpansion
for %%a in (folder\*) do (
echo Processing file = %%~nxa
echo Processing file extension %%~xa
echo Processing file name = %%~na
SET file_extension = %%~xa
echo !file_extension!
echo %%~xa
)
pause