When I execute the following at the DOS command line, I have no problem:
for /f %k in ('dir/b/s *.xml') do if exist Z:%~pk*.* xcopy %k z:%~pnxk
However, when I put this in a DOS .bat file, it dies on starting at %k. The command line ends up looking like:
for /f ~pk*.* xcopy ~pnxk
and I get this error: xcopy was unexpected at this time.
I suspect this is because the .bat expects a command line parameter in %k, correct? Does anyone know how I can fix this? This a great command provided by billious, but I need to get it working in a batch file.