0

I have a batch file that's supposed to rename every file in a directory, but it keeps renaming itself and then won't continue with the script afterwards.

for /r %%b in (*) do (
    ren %%b !random!
)

The question could be a clone of this one but even after reading this in combination with this, I still can't figure it out.

Either I'm dumb and the answer is really simple, or it's because I'm tired and I can't think straight.

iBug
  • 35,554
  • 7
  • 89
  • 134
Døzer
  • 3
  • 4

2 Answers2

0

If that's really what you want try:

For /R %%A In (*) Do If /I Not "%%A"=="%~f0" Ren "%%A" %RANDOM%
Compo
  • 36,585
  • 5
  • 27
  • 39
0

Ok, so what Compo said worked, but I had to change %0 to %~f0 to get the full directory, filename and file extension.

Døzer
  • 3
  • 4