Have a go at this:
@echo off
for /R "D:\LiDAR_Data\LiDAR_DATA_EBA\" %%G in (*.laz) do (
echo File Extension only: "%%~xG"
echo FileName with Extension: "%%~nxG"
echo FileName without Extension: "%%~nG"
echo Full path and name: "%%G"
echo Directory to file only: "%%~pG"
echo Drive and directory is: "%%~dpG"
)
pause
Notice how we get the various parts of the string. For more on variable handling, simply run for /?
from command line and read the help.
So a little closer to what you actually want, based on your attempt.
@echo off
for /R "D:\LiDAR_Data\LiDAR_DATA_EBA\" %%G in (*.laz) do (
echo FileName "%%~nxG"
echo Directory "%%~dpG"
echo Processing file "%%~nxG"
)
pause
EDIT
As per your last comment to see only the last folder where the file exists:
@echo off
for /R "D:\LiDAR_Data\LiDAR_DATA_EBA\" %%G in (*.laz) do (
echo FileName "%%~nxG"
echo Directory "%%~dpG"
echo Processing file "%%~nxG"
for %%i in ("%%~dpG\.") do echo Last Folder "%%~nxi"
)
pause