#1 : 01/12-20 13:43 Saman Izadi
Posts: 3
|
Hi! I'm having a problem to swap 2 file names... not only a part.. like "1 - 2.mp3" to "2 - 1.mp3"
I want to swap 2 file name .. like "1.mp3" and "2.mp3" to "2.mp3 (But it has 1.mp3 files)" and "1.mp3 (With 1.mp3 files), I want to use this as a "File randomizer" as I use this app a lot... I'll be thankful if you help me Thanks |
#2 : 01/12-20 17:14 David Lee
Posts: 1125
|
Plaease can you try to be a bit clearer about what you are trying to achieve?
It looks like you will only have two files in the list and you want to swap the names between the two files. However it isn't clear what you mean about using it as a "File randomizer". Some examples would be helpful. |
#3 : 01/12-20 17:58 Saman Izadi
Posts: 3
|
Reply to #2:
I mean like X (X>1) to Y files..like 1.png --> 3.png (1.png files) 2.png--> 4.png (2.png files) 3.png -- > 1.png (3.png files) 4.png --> 2.png (4.png files) I'm also ok with this mode 1.png -->4.png 2.png-->1.png 3.png -->2.png 4.png --> 3.png (All with their first name files) In a nutshell... I just want to swap multiple files names..not randomize them.. just swapping the name..but in more than 1 files..in any method... 2 by 2... full random... next file name...any will work...thanks :-) example : X.png --> Y.png (X files) Y.png --> Z.png (Y files) Z.png -->X.png (Z files) |
#4 : 01/12-20 19:22 David Lee
Posts: 1125
|
Reply to #3:
You can do this using a script. It will be very straightforward simply to increment the filenames eg for n files 1->2, 2->3, 3->4, ... n->1 etc Script method: return app.getItem((item.index+1)%app.itemCount).name; The result will return errors for all files since all the filenames already exist in the list so set the Name collision rule to "append number" and the separator to a character that will never appear in a filename (eg "#") Run the batch and reload all the renamed files into the list Run a second pass with a Replace method to remove the appended numbers... Replace: "#*" With: leave blank It will also be easy to fully randomize the swaps but this will require some more complex JavaScript. Basically you would use "Math.random() * count" to generate a random index and return app.getItem(index).name; However you will have to keep track of which index numbers have already been used and keep generating new random numbers until you get an unused one. I've previously posted code to generate unique random numbers: https://www.advancedrenamer.com/forum_thread?for um_id=5990 See if that helps. |
#5 : 02/12-20 10:20 Saman Izadi
Posts: 3
|
Reply to #4:
Thanks a lot! at first I didn't understand that much.. but now I can easily do this thing! also... 3 things to note 1 - If I use a seprate thing that's rare like $$.. I can't just use replace $$ with nothing... I need to add a 001 at the end cuz it does that when there's a file with the same name.. so I need to say replace $$001 with nothing 2 - I can just select all and "Random Orgnization" and it will be fully randomized! 3 - I can change +1 to anything ... like +10 to make things more randomized again... Thanks a lot :-) |
#6 : 02/12-20 12:07 David Lee
Posts: 1125
|
Reply to #5:
Glad it helped! Re your comments... 1) You should Replace: "$$*" With: nothing. Note that this is not a regular expression so leave that box unticked. The regex version would be "$$.*" 2) Well spotted! Should have been obvious but I never thought about randomizing the list before renaming. I'll remember that trick. |