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.

2 Answers 2

0

If that's really what you want try:

For /R %%A In (*) Do If /I Not "%%A"=="%~f0" Ren "%%A" %RANDOM% 
Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

You could have changed that to, %~dpnx0 or as per my now edited answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.