I'm getting an incorrect syntax error that I can't seem to identify
for %%f in (%Source%\*DebugLog.Config) do %%f ren %%f "%Source%\%ProjectName%.*DebugLog.Config".
There are several mistakes in your batch file (2 of which I made myself).
As pointed out to me in comments elsewhere by dbenham:
The REN target cannot include drive or path. It must be name and extension only
Use of the simple FOR runs the risk of renaming a file more than once - not good :-( Better to use FOR /F with DIR /B
See his answer add “text” to end of multiple filenames for more explanation on the above.
In addition do %%f is meaningless, it should be just do.
Here is a working batch file:
@echo off
pushd %source%
for /f "delims= eol=:" %%f in ('dir /b /a-d *DebugLog.Config') do ren "%%f" "%ProjectName%.%%f"
popd
Further Reading
- An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
- dir - Display a list of files and subfolders.
- for /f - Loop command against the results of another command.
- popd - Change directory back to the path/folder most recently stored by the PUSHD command.
- pushd - Change the current directory/folder and store the previous folder/path for use by the POPD command.
- ren - Rename a file or files.