Suppose I wanted to echo every executable inside the %programfiles% folder
cd %programfiles%
for /r . %i in (*.exe) do echo "%~i"
but it yields
c:\program files\program1\program1.exe
c:\program files\program2\program2.exe
and I want
program1\program1.exe
program2\program2.exe
How to remove those prefixes?
You could use the string replace function of batch