Jump to content

Recommended Posts

Posted

I would like to rename a few thousand text files through batch to a randomly-generated GUID filename. Does anyone know how to do this? I'm thinking it might be possible by using a third-party command-line GUID generator and setting a variable to the program's output, then creating a FOR loop.


Posted

Yes, I've found uuidgen.exe already. It outputs a single GUID without the brackets, so I redirected its output to a temporary file:

@echo off

:loop
uuidgen.exe > temp.dat
for /f %%i in (temp.dat) do set tempuuid=%%i
goto loop

That generates an infinite amount of GUID's for my use. My next step was to then call another batch file and do a "for" loop to rename all *.txt files to %tempguid%. That's when I first found out that "environmental variables" apply only to a single cmd.exe session. Any help is appreciated.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...