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. |
|
|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
rename photo by random size
Is there a program that can rename a directory of photos randomly?
Perhaps by size? Or by last access? Or by number of colors. Whatever. Almost none have exif so rename by exif would be nice but won't work. Most renames like iv seem to rename based only on file name. |
Ads |
#2
|
|||
|
|||
rename photo by random size
On 15 Dec 2018, Jean Fredette wrote in
alt.windows7.general: Is there a program that can rename a directory of photos randomly? Perhaps by size? Or by last access? Or by number of colors. Whatever. Almost none have exif so rename by exif would be nice but won't work. Irfanview has many bulk rename options. Check it out. |
#3
|
|||
|
|||
rename photo by random size
In message , Jean Fredette
writes: Is there a program that can rename a directory of photos randomly? Do you mean rename the directory, or the files within it? Perhaps by size? Or by last access? Or by number of colors. Whatever. Almost none have exif so rename by exif would be nice but won't work. IV can rename by file size ($S), number of megapixels ($m) ... presumably those don't use exif data. Most renames like iv seem to rename based only on file name. Au contraire (-: -- J. P. Gilliver. UMRA: 1960/1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf Q. How much is 2 + 2? A. Thank you so much for asking your question. Are you still having this problem? I'll be delighted to help you. Please restate the problem twice and include your Windows version along with all error logs. - Mayayana in alt.windows7.general, 2018-11-1 |
#4
|
|||
|
|||
rename photo by random size
On Sat, 15 Dec 2018 14:13:58 -0600, Jean Fredette
wrote: Is there a program that can rename a directory of photos randomly? Perhaps by size? Or by last access? Or by number of colors. Whatever. Almost none have exif so rename by exif would be nice but won't work. Most renames like iv seem to rename based only on file name. "Randomly" might make it tricky, but for all of my bulk renaming chores I turn to Bulk Rename Utility. https://www.bulkrenameutility.co.uk/Main_Intro.php If I wanted to rename based on size, I'd simply click the size column header, then apply an incrementing serial number to each file as a prefix. For example, once the files have been sorted by size or date accessed, I'd specify a prefix of 101 or 1001, depending on the number of files, increment 1, separator " - ", and let'er rip. Later, if you want to name them by a different criteria, you can easily remove the serial number, do the sort another way, and reapply a serial number. BRU is insanely configurable. -- Char Jackson |
#5
|
|||
|
|||
rename photo by random size
posted:
IV can rename by file size ($S), number of megapixels ($m) ... presumably those don't use exif data. I want to rename the files not the directory. If IV renamed randomly I am fine but I long tried IV doing this. What is wrong with my test of IV rename by file size? I open one jpeg file in the directory to IV. I press the "b" key to begin batch operation. I press "options" in the "batch rename settings" part. There are no related options to rename based on file size. (The batch rename order will be based on the original filename order.) Is there some other bulk rename feature somewhere else in IV? It doe not need to rename with pure random but it should not be based on alphabetical order. |
#6
|
|||
|
|||
rename photo by random size
In message , Jean Fredette
writes: posted: IV can rename by file size ($S), number of megapixels ($m) ... presumably those don't use exif data. I want to rename the files not the directory. If IV renamed randomly I am fine but I long tried IV doing this. What is wrong with my test of IV rename by file size? I open one jpeg file in the directory to IV. I press the "b" key to begin batch operation. I press "options" in the "batch rename settings" part. So far so good ... There are no related options to rename based on file size. (The batch rename order will be based on the original filename order.) Is there some other bulk rename feature somewhere else in IV? It doe not need to rename with pure random but it should not be based on alphabetical order. In the window that opens when you click Options, headed "Batch rename settings", click Help. Scroll down. You will see $S - file size, and $m - number of megapixels. So close the help, and change whatever's in the "Name pattern" box to $S. Now select your files, and start renaming ... This is IV 4.51, but I think it's been the same for a while. -- J. P. Gilliver. UMRA: 1960/1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf This was before we knew that a laboratory rat, if experimented upon, will develop cancer. [Quoted by] Anne ), 1997-1-29 |
#7
|
|||
|
|||
rename photo by random size
"Jean Fredette" wrote
| Is there some other bulk rename feature somewhere else in IV? | It doe not need to rename with pure random but it should not be based on | alphabetical order. 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? 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. |
#8
|
|||
|
|||
rename photo by random size
posted:
In the window that opens when you click Options, headed "Batch rename settings", click Help. Scroll down. You will see $S - file size, and $m - number of megapixels. So close the help, and change whatever's in the "Name pattern" box to $S. Now select your files, and start renaming ... This is IV 4.51, but I think it's been the same for a while. I only later understood what you are trying to tell me. Let me write what happens with IV 4.5.1 - 32 bit as I try slowly. I open up a directory of a few thousand images of various types. I only want to rename the base file name and keep original extensions. I do not want the current order of the file names which is alphabetical. I want the order of file names to be random (or at least mostly random). I click twice on a file to open it up in iv which is my default pic viewer. I press the "b" keyboard key to begin batch mode. The "Batch conversion" window opens up. I press the "Add all" button to add all the thousands of image files. Under the heading of "Batch rename settings" is a "Name pattern". To the right of that name pattern is an "Options" button. I click that Options button which has a "Name pattern" again. To the right of the "$N" and "#" example is a "Help" button. I press that "Help" button which brings up "Text/Pattern Options" help. Some of those text pattern options are below. $S - file size $m - number of megapixels $B - image bits per pixel $p - image DPI $R - image aspect ratio (width / height) $I - all IPTC data Closing that Help I try this pattern Name pattern: $S$m$B$p$R$I### And then I press the "Start Batch" button. That gives me random file names of 497.88 KB1.19 MP2496(0.87)001.jpg 473.31 KB1.12 MP2496(1.65)002.jpg 810.52 KB2.35 MP2496(0.95)003.jpg 608.40 KB1.81 MP2496(1.24)004.jpg 487.22 KB1.32 MP2496(1.94)005.jpg 1023.52 KB1.97 MP2496(1.14)006.jpg 924.00 KB2.12 MP2496(0.49)007.jpg 407.16 KB0.61 MP2496(1.72)008.jpg 591.69 KB0.93 MP2496(1.12)009.jpg 417.45 KB0.78 MP2496(1.34)010.jpg 259.61 KB0.44 MP2496(2.37)011.jpg 449.83 KB0.99 MP2496(1.05)012.jpg 591.44 KB0.96 MP24300(1.09)013.jpg 558.63 KB0.98 MP2496(1.07)014.jpg 569.74 KB1.13 MP2496(0.92)015.jpg Now that the file name order is random, I can run another batch rename Name pattern: image### Now the images are in a pseudo random order. It works ok. Thank you for helping me find the other randomizing values! |
#9
|
|||
|
|||
rename photo by random size
"Randomly" might make it tricky, but for all of my bulk renaming chores I turn to Bulk Rename Utility. https://www.bulkrenameutility.co.uk/Main_Intro.php If I wanted to rename based on size, I'd simply click the size column header, then apply an incrementing serial number to each file as a prefix. For example, once the files have been sorted by size or date accessed, I'd specify a prefix of 101 or 1001, depending on the number of files, increment 1, separator " - ", and let'er rip. Later, if you want to name them by a different criteria, you can easily remove the serial number, do the sort another way, and reapply a serial number. BRU is insanely configurable. Thank you for BRU suggestion which helped me find these to test. BRU https://www.bulkrenameutility.co.uk/Download.php AdvancedRenamer https://www.advancedrenamer.com/ RenameExpert https://www.rename-expert.com/featur...ile_names.aspx |
#10
|
|||
|
|||
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% ) |
#11
|
|||
|
|||
rename photo by random size
Jean Fredette wrote:
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. It sounds like you're trying to override the playback order in a screensaver, picture frame, or smart TV. By appending a prefix to the file name, the alphabetical order can be overridden. 001_horse 002_another_white_cow 003_cat 004_another_chicken 005_dog 006_a_brown_cow 007_chicken 008_a_white_cow 009_a_big_dog 010_yet_another cow 011_a_small_cat On a later incantation, you might seek 001_another_white_cow 002_dog and that's the order they will play in. Here is a deck shuffling code. When solving a problem, first I look for some code I can borrow. https://www.rosettacode.org/wiki/Knuth_shuffle#AWK You can make a script generator in awk (gawk). dir input.txt gawk -f shuffle2.awk input.txt output.txt notepad output.txt # visual check all is good ren output.txt output.bat output.bat # do the rename in Command Prompt # The rename can be done from AWK # but it's a bit clumsy. Now, all you have to do, is write the program. I'm using the KISS principle here, to keep scripting time to 30 minutes or less. Borrowing a little code, saves time. ******* shuffle2.awk MSDOS batch generator ******* # Program to shuffle filenames. # Can be applied to the directory, again and again. # # Input: # # hello.jpg # A brand new file added to the directory # 0001__goodbye.jpg # An old file needing renaming without hdr addn # # Output: # # ren 0001__goodbye.jpg 0001__goodbye.jpg # the order is random # ren hello.jpg 0002__hello.jpg # a second run will flip the order # # For interactive input, type ctrlz to indicate end of stdin # # gawk -f shuffle2.awk # gawk -f shuffle2.awk input.txt my_msdos_bat.bat BEGIN { srand(systime()) # seed using epoch time in seconds maxfiles = 10000 # a power of ten, for number plan # stick to a scheme once started!!! # 0000__ 0001__ ... 9999__ headlen = 6 for (k=1; k10000; k++) { prechk[ sprintf("%04d__", k) ] = k } # catch reused headers k=1 # use as input counter } # Shuffle an _array_ with indexes from 1 to _len_. # Reuse: https://www.rosettacode.org/wiki/Knuth_shuffle#AWK # function shuffle(array, len, i, j, t) { for (i = len; i 1; i--) { # j = random integer from 1 to i j = int(i * rand()) + 1 # swap array[i], array[j] t = array[i] array[i] = array[j] array[j] = t } } { array[ k++ ] = $0 } # load list of filenames from stdin END { k-- # correct overshoot by one shuffle( array, k ) # for (m = 1; m = k; m++) { head = substr( array[m], 1, headlen ) totlen = length( array[ m ] ) tail = substr( array[m], 7, totlen-6 ) if (head in prechk) { # substitute out the lead chars printf( "ren %s %04d__%s\n" , array[ m ], m, tail ) } else { # add new scheme as prefix to name printf( "ren %s %04d__%s\n" , array[ m ], m, array[m] ) } } } ******* shuffle2.awk MSDOS batch generator ******* Gawk.exe is available here, in the binaries section. This program should not need any library DLLs and is (thankfully) self-contained. http://gnuwin32.sourceforge.net/packages/gawk.htm Gawk version 4 is available in Windows 10, in the Linux Bash environment. This Gawk 3 version from gnuwin32 however, is actually "Windows friendly" on line endings, which is why I'm still using it. Paul |
#12
|
|||
|
|||
rename photo by random size
posted:
It sounds like you're trying to override the playback order in a screensaver, picture frame, or smart TV. Yes. I want to jumble images to not clump. IV doesn't really have anything that is random. By appending a prefix to the file name, the alphabetical order can be overridden. Thank you. The gawk looks good but does it do more than RandomNames? https://www.howtogeek.com/57661/stup...n-a-directory/ That script has the option to undo and to prepend to the file name. https://www.howtogeek.com/wp-content...andomNames.zip REM 0 = Rename the file randomly. SET PrependOnly=0 REM 1 = Prepend the existing file name with randomly generated string. SET PrependOnly=1 REM 1 = Undo changes according to the translation file. SET Undo=1 |
#13
|
|||
|
|||
rename photo by random size
Jean Fredette wrote:
posted: It sounds like you're trying to override the playback order in a screensaver, picture frame, or smart TV. Yes. I want to jumble images to not clump. IV doesn't really have anything that is random. By appending a prefix to the file name, the alphabetical order can be overridden. Thank you. The gawk looks good but does it do more than RandomNames? https://www.howtogeek.com/57661/stup...n-a-directory/ That script has the option to undo and to prepend to the file name. https://www.howtogeek.com/wp-content...andomNames.zip REM 0 = Rename the file randomly. SET PrependOnly=0 REM 1 = Prepend the existing file name with randomly generated string. SET PrependOnly=1 REM 1 = Undo changes according to the translation file. SET Undo=1 I specifically did not make this a full featured "add" "re-randomize" "remove" program. I could do that, but elected not to. This is what you call a "quick and dirty". The point of presenting it at all, is to as much show an approach, as to give you finished software. Note that: 1) The "program" I provided, does not rename files itself. It only generates an MSDOS batch file containing rename commands. This is intended to take the "danger" out of the program. It also saves me adding a ton of "if-then-else" that might obscure the simple nature of the program. You can actually do the rename step in gawk too, by calling Windows shell routines to do it. I elected not to attempt it. If I spent 24 hours working on the code, I could add everything. 2) The "program" reuses code. I was too lazy to learn how to shuffle a deck, so I borrowed some code to do it. 3) The "program" has a minimum of command line options (effectively zero options). They can be added, but that is "feature creep". And the program isn't really all that functional to begin with, because the real work is done when you execute the output batch file. Anything that renames or deletes files, I am *really* *really* careful. It takes a lot of safety testing to make sure I didn't screw up. And I *have* lost files (only one or two) via programming accidents in the past. That's where my careful methodical approach for full featured programs come from. From losing files... The intended usage scenario is this: 1) Copy selected files for the screensaver into a new folder. I.e. *Don't* use your only copy for this purpose. 2) cd /d /path/to/folder dir input.txt run the gawk program to generate a batch notepad output.txt remove lines that don't belong, then save ren output.txt output.bat ./output.bat # folder re-randomized 3) If needing to re-randomize the folder, repeat step two. If a file begins with 0001_goodbye.jpg, the gawk program can place 0005_goodbye.jpg as its new name, making it the fifth image to play on the screensaver. I tried to make the gawk program so it could be run more than once, without adding command line parameters to pass to it. ******* There is no collision detection code in the program, as my reasoning is, it isn't necessary. Don't for example, *manually* place the following in the folder. This destroys my going-in assumptions about the need for collision detection code. My little program can't do this, without human interference to spoil my assumptions about uniqueness. 0001__goodbye.jpg 0005__goodbye.jpg The random change, could attempt to ren 0001__goodbye.jpg 0005__goodbye.jpg while "0005__goodbye.jpg" already exists. As long as you toss names with no conflicts in there in the first place cat.jpg dog.jpg squirrel.jpg everything should work. If adding files, you *still* want the root filename to be unique. Here, I added an elephant to a previously-randomized run. You can add files to the folder, just as long as the filename was as unique as it would have been sitting in the original folder. If you could not copy the elephant to the original folder without causing some other elephant to be deleted, then placing that elephant in this working folder will also cause a problem. In the following example, the elephant is unique, so there is no problemo. 0001__dog.jpg 0002__cat.jpg 0003__squirrel.jpg elephant.jpg gives... 0001__cat.jpg 0002__elephant.jpg 0003__dog.jpg 0004__squirrel.jpg Adding collision detection is easy too, but it's feature creep and part of a more thorough effort. Adding if-then-else to cure "stupid stuff" is essential to well-written programs. This isn't a well written program. It's a Q&D demo. If I needed "sufficient" control over the program, I'd write it in C code. I have stat() and other resources there. In terms of input format, each line of text in the input.txt is assumed to be a file name. Let's run a thought experiment... in de gotta da vida.jpg will be renamed to ren in de gotta da vida.jpg 0001__in de gotta da vida.jpg Yup, a disaster. It needs double quotes added to the printf. ren "in de gotta da vida.jpg" "0001__in de gotta da vida.jpg" So here is a five line "chunk" to snip out and replace, to add the quotes. Modify the previously-posted file with this. if (head in prechk) { # substitute out the lead chars printf( "ren \"%s\" \"%04d__%s\"\n" , array[ m ], m, tail ) } else { # add new scheme as prefix to name printf( "ren \"%s\" \"%04d__%s\"\n" , array[ m ], m, array[m] ) } And here is the fix running my test case. Now the rename has quotes to protect file names. I'm using interactive mode to enter a two line test case here. https://i.postimg.cc/HsFdmLmj/add-quotes.gif I only write a couple of these pieces of code per year, so it's not like I'm a code-writing machine or anything. Some will "enjoy a new hobby" more than others :-) Paul |
#14
|
|||
|
|||
rename photo by random size
On Sun, 16 Dec 2018 01:22:51 -0500, Paul wrote:
In terms of input format, each line of text in the input.txt is assumed to be a file name. Let's run a thought experiment... in de gotta da vida.jpg will be renamed to ren in de gotta da vida.jpg 0001__in de gotta da vida.jpg LOL, I think you just copied Star Trek episode S02E23, "The Omega Glory". :-) CLOUD: When you would not say the holy words, of the Ee'd Plebnista, I doubted you. KIRK: I did not recognise those words, you said them so badly, Without meaning. ELDER: No! No! Only the eyes of a chief may see the Ee'd Plebnista. KIRK: This was not written for chiefs. (general consternation) Hear me! Hear this! Among my people, we carry many such words as this from many lands, many worlds. Many are equally good and are as well respected, but wherever we have gone, no words have said this thing of importance in quite this way. Look at these three words written larger than the rest, with a special pride never written before or since. Tall words proudly saying We the People. That which you call Ee'd Plebnista was not written for the chiefs or the kings or the warriors or the rich and powerful, but for all the people! Down the centuries, you have slurred the meaning of the words, 'We, the people of the United States, in order to form a more perfect union, establish justice, ensure domestic tranquillity, provide for the common defence, promote the general welfare, and secure the blessings of liberty to ourselves and our posterity, do ordain and establish this constitution.' These words and the words that follow were not written only for the Yangs, but for the Kohms as well! "in de gotta da vida" reminded me of "In-A-Gadda-Da-Vida" which of course is a drunken slurring of "In The Garden of Eden". Good stuff. Thanks for the flashback. https://en.wikipedia.org/wiki/The_Omega_Glory http://www.chakoteya.net/StarTrek/54.htm https://en.wikipedia.org/wiki/In-A-Gadda-Da-Vida -- Char Jackson |
#15
|
|||
|
|||
rename photo by random size
"Jean Fredette" wrote
| The gawk looks good but does it do more than RandomNames? | https://www.howtogeek.com/57661/stup...n-a-directory/ | | That script has the option to undo and to prepend to the file name. | https://www.howtogeek.com/wp-content...andomNames.zip | I tried that script. It works fine. So it looks to me like your problem is solved. |
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|