Continuing from Pete's example above, to do it directly in the cmd window, use a single %
, eg:
cd c:\test\folder A
for %X in (*)do echo %~nxX
(Note that special files like desktop.ini will not show up.)
It's also possible to redirect the output to a file using >>
:
cd c:\test\folder A
for %X in (*)do echo %~nxX>>c:\test\output.txt
For a real example, assuming you want to robocopy all files from folder-A to folder-B (non-recursively):
cd c:\test\folder A for %X in (*)do robocopy . "c:\test\folder B" "%~nxX" /dcopy:dat /copyall /v>>c:\test\output.txt
and for all folders (recursively):
cd c:\test\folder A for /d %X in (*)do robocopy "%X" "C:\test\folder B\%X" /e /copyall /dcopy:dat /v>>c:\test\output2.txt