A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Windows 10 » Windows 10 Help Forum
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Batch file to uniquely nmame & random rename JPEG images [randomnames.bat]



 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 15th 20, 02:23 AM posted to alt.comp.os.windows-10,alt.msdos.batch,rec.photo.digital
Arlen Holder
external usenet poster
 
Posts: 186
Default Batch file to uniquely nmame & random rename JPEG images [randomnames.bat]

I was re-populating a re-imaged system due to BSOD corrupting the boot
where I had a devil of a time _finding_ this old randomnames.bat file
which will randomly name any number of JPEG files to unique names each.

I use it when I take a bunch of screenshots over long periods of time, and
edit them one by one, as needed, where the names aren't in the order of the
screenshots anyway, and there are too many to rename manually, so I rename
them randomly - which makes each one distinct.

If you need it, it's useful.
o If you don't need it - it's just a sample of randomizing algorithms.

@ECHO OFF
ECHO Random Names
ECHO Written By: Jason Faulkner
ECHO HowToGeek.com
ECHO.
ECHO.
REM
https://www.howtogeek.com/57661/stup...n-a-directory/
REM https://www.howtogeek.com/wp-content...andomNames.zip

REM Randomly renames every file in a directory.

SETLOCAL EnableExtensions EnableDelayedExpansion

REM 0 = Rename the file randomly.
REM 1 = Prepend the existing file name with randomly generated string.
SET PrependOnly=0

REM 1 = Undo changes according to the translation file.
REM Undo will only work if a previously generated "__Translation.txt" is in
the same folder.
REM If you delete the translaction file, you will not be able to undo the
changes!
SET Undo=0


REM
--------------------------------------------------------------------------
REM Do not modify anything below this line unless you know what you are
doing.
REM
--------------------------------------------------------------------------

SET TranslationFile=__Translation.txt

IF NOT {%Undo%}=={1} (
REM Rename files
ECHO You are about to randomly rename every file in the following folder:
ECHO %~dp0
ECHO.
ECHO A file named %TranslationFile% will be created which allows you to
undo this.
ECHO Warning: If %TranslationFile% is lost/deleted, this action cannot be
undone.
ECHO Type "OK" to continue.
SET /P Confirm=
IF /I NOT {!Confirm!}=={OK} (
ECHO.
ECHO Aborting.
GOTO :EOF
)

ECHO Original Name/Random Name %TranslationFile%
ECHO ------------------------- %TranslationFile%

FOR /F "tokens=*" %%A IN ('DIR /A:-D /B') DO (
IF NOT %%A==%~nx0 (
IF NOT %%A==%TranslationFile% (
SET Use=%%~xA
IF {%PrependOnly%}=={1} SET Use=_%%A

SET NewName=!RANDOM!-!RANDOM!-!RANDOM!!Use!
ECHO %%A/!NewName! %TranslationFile%

RENAME "%%A" "!NewName!"
)
)
)
) ELSE (
ECHO Undo mode.
IF NOT EXIST %TranslationFile% (
ECHO Missing translation file: %TranslationFile%
PAUSE
GOTO :EOF
)
FOR /F "skip=2 tokens=1,2 delims=/" %%A IN (%TranslationFile%) DO RENAME
"%%B" "%%A"
DEL /F /Q %TranslationFile%
)
--
What I love about Usene is it's filled with useful hints & ideas.
 




Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off






All times are GMT +1. The time now is 12:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 PCbanter.
The comments are property of their posters.