#1 : 19/02-23 11:25 Beth
Posts: 2
|
Hi
I have a use-case where several thousand files would be renamed using random selection from a pre-prepared word list using between 2-4 words per file name. The need is to create names that are unique and memorable rather than just a string of random alpha numeric characters. Is this possible in Advanced Renamer? Many thanks B |
#2 : 20/02-23 10:24 David Lee
Posts: 1125
|
Straightforward to do using a Script method but it will take a bit of programming effort.
Save your word list to a text file, one to a line. Then, in the Pre-Batch Script, read the contents of the file, line-by-line, into an array using the <File line:'> tag. This tag is not documented in the User Guide but see the entry for Version 3.61 (14 Jan 2014) at https://www.advancedrenamer.com/whatsnew You can then generate filenames in the main script by extracting random words from the array, using Math.random() to generate random numbers. You will have to keep track of used filenames to prevent duplication. |
#3 : 20/02-23 13:40 David Lee
Posts: 1125
|
Reply to #2:
To get you started: this script will rename files with a single word chosen randomly from a list stored in a text file c:\wordList.txt... Pre-batch Script: var words = []; var usedWords = {}; nWords=0; nUsedWords=0 while (line = app.parseTags('<File line:' + (nWords+1) + '::"c:\\wordList.txt">')) { words[nWords] = line; nWords ++; } Main Script: if (nWords > nUsedWords) { do { word = words[Math.floor(Math.random()*nWords)]; } while (usedWords[word] != undefined); usedWords[word] = 1; nUsedWords++; return word; } |