View Single Post
  #10  
Old December 15th 18, 10:29 PM posted to alt.windows7.general
Jean Fredette
external usenet poster
 
Posts: 47
Default rename photo by random size

posted:

I see the default option as image1, image2, etc.
You seem to want to make the names non-informative.
Isn't that a good method?


I do not actually care what the image name is.
It just needs to be randomly ordered.

Let's take a made up example of the following pictures
a white cow
another white cow
yet another cow
horse
chicken
another chicken
dog
a big dog
cat
a small cat
a brown cow

I want the order of those to be random kind of like this
horse
another white cow
cat
another chicken
dog
a brown cow
chicken
a white cow
a big dog
yet another cow
a small cat

The order doesn't have to be "really" random.
Just not in the original order which had groupings of similar pictures.
I want to break up the groupings of similar pictures.

The final result can be any name as long as the order is "random".

image001 which was horse
image002 which was another white cow
image003 which was cat
image004 which was another chicken
image005 which was dog
image006 which was a brown cow
image007 which was chicken
image008 which was a white cow
image009 which was a big dog
image010 which was yet another cow

If you were to rename based on size or file time
you'd need to deal with possible repetitions. You'd
also need to access the file to do it.


I found this batch script which I think handles repetitions.

@ECHO OFF
ECHO Random Names
ECHO Written By: Jason Faulkner
ECHO HowToGeek.com
ECHO.
ECHO.

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 This will only work if the file "__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%
)
Ads