"move/ren" gives syntax error, I can't figure solution

125 views Asked by At

I am trying to rename some folders with a batch-file, but everything I try gives me syntax errors. Here is what I have currently:

for /d %%a in (%cd%\*.*) do call :moveandrename %%~nxa %%a
.
.
.
:moveandrename
if exist %2\%1.pdf if exist %2\%1.xml move "%2" "%~dp0\export\_verarbeitet"
ren "%~dp0\export\_verarbeitet\%1" "%1_verarbeitet_%date%_%time%"

Any suggestions?

1

There are 1 answers

1
Lukas On

I found the bug...

adding "%time" to foldername caused syntax error, this is how it works

mkdir export\1
mkdir export\_verarbeitet
rem.>export\1\1.pdf
rem.>export\1\1.xml
for /d %%a in (%~dp0export\*.*) do call :moveandrename %%~nxa %%a
goto :eof
:moveandrename
if exist "%~2\%~1.pdf" if exist "%~2\%~1.xml" move "%2" "%~dp0export\_verarbeitet\"
ren "%~dp0export\_verarbeitet\%1" "%1_verarbeitet_%date%"
pause
goto :eof