Thus far, whenever I've created a batch file (or mooched one from someone else), I've just saved it, run it, and hoped it worked. Now I have a batch file that paultomasi provided to me that would be fantastic if I could get it running. Unfortunately, it won't run.
1. I would imagine it isn't possible to step through a batch file (maybe I'm wrong). I suppose I could lace the file something like this as alternative. Examining bat_debug.txt for the benchmarks that appeared and those that didn't would enable me to figure out where the file went bad.
Echo %Date%, %Time%, 'benchmark 1', >> C:\bat_debug.txt
Echo %Date%, %Time%, 'benchmark 2', >> C:\bat_debug.txt
Echo %Date%, %Time%, 'benchmark 3', >> C:\bat_debug.txt
2. It would also be wonderful to get the BAT file to throw actual error codes. Is that possible?
Here's the code paultomasi provided. The objective of the code is extract files out of a complex directory structure and place copies in the parent directory. The code also appends a "(1)", "(2)", "(3)"... to redundant file names to prevent naming conflicts.
set rootfolder=Project Folder
for /d %%a in ("%rootfolder%\*") do (
for /r "%%a" %%b in (*) do (
if exist "%rootfolder%\%%~nxb" (
call :duplicatefile "%%b"
) else (
move "%%b" "%rootfolder%\"
set /a count+=1
if exist "%rootfolder%\%~n1 (%count%)%~x1" goto :loop
move "%~dpn1 (%count%)%~x1" "%rootfolder%"