32
20
for /r %f in (*) do echo %f
Gives the output filename along with the entire path
\path\to\dir\<filename>
How do i get just the <filename>
without the path included? I need to use that 'filename' string.
Also, is it possible to do the following, once the filename is acquired?
for /r %%f in (*) do (
echo "blah blah blah 'filename'" >> blahblah_filename.txt
)
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation) – PapaAtHome – 2018-07-02T09:08:36.483
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau – 2018-07-02T12:36:33.6603
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on the
– martineau – 2012-10-18T03:31:33.347for
command.