Link to home
Start Free TrialLog in
Avatar of damijim
damijimFlag for United States of America

asked on

DOS Bulk Filename & Randomization

I've read some other threads about bulk renaming of files, but I can't find one that fits my situation perfectly.

I'm running WinXP SP2, in DOS (cmd.exe, anyway), I have a local directory with many .jpg files. I want to bulk rename them to a random number and keep the .jpg extension.

For example:
(06-01-01)003_3.JPG to uf5hs6k.jpg
DSC00952.JPG to opku4.jpg

I do not care about the length of the filename very much. I'd like to keep it fairly short and there are roughly 300 jpg files. My intent in the randomization of the file name is so that they are no longer in the alphanumeric order that they are currrently in. So, I don't want to bulk rename to a static name and increment a number (or letter) at some point. Thanks!
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland image

Pfrank is a very flexible file renaming program - they claim it can do anything see http://www3.telus.net/pfrank/
I don't know of any tool that will randomly assign names.   The simplest solution here is probably to write a short program in C+ or Basic that parses the directory and changes each file to a random name.   It's fairly simple to generate a random string in either language => so it could simply go through the directory and rename each file to <randomstring>.jpg

I'd add the Programming area to your zones and see if someone is willing to throw together a short program to do this for you :-)

... or you might provide some detail on WHAT your goal is here => you may be able to do what you want without actually renaming all of the files :-)
Avatar of damijim

ASKER

I may just end up SSH'ing to unix box and SSH'ing back into my local machine to do it. I'm trying to PFrank thing out right now.

My goal: I have a program (not mine - already compiled) that goes through each file and processes them one by one in order of name, but I want them processed in random order (not an option in the program).
Avatar of damijim

ASKER

I was hoping for a fairly simple DOS command.. :)
I just played around with PFrank a bit => it does a lot of things ... but choosing a Random name doesn't seem to be one of them :-)

... Perhaps you should write the author and point out that you found something it can't do !! --> he may just add the feature for you :-)

There aren't any simple DOS commands that will do this ... it is (as I suspect you know) a rather unusual request :-)
Avatar of damijim

ASKER

yeah, I can't find a way to do it in PFrank either.

I was thinking in PFrank, I could just use a few of the bulk renames.. like "only keep 4th and 5th char in prefix" then do like something and then some other command, but I don't know... i don't think it can do it... eitherway, when I start PFrank, it complains about not finding "PFrank\PFrankUser.py"... I'm assuming it needs python installed too?
==========================================================================
Oct 19 2007 18:28:35    ***User Command Edit Problem
Error: No associated application for the python text file   'C:\Program Files\PFrank\PFrankUser.py'

Thanks anyway though! How do I add another zone to my topic? Running around SSH tunnels to get back to my corporate computer is a pain.
Not sure how you add a zone ==> I haven't asked any questions since the new interface was added this year.   If there's not a button on your question's page to do it; I'm sure you can simply post a Community Support question asking that another zone be incorporated and a moderator will do it.
Avatar of damijim

ASKER

Nope, no button to add another zone.... unless someone can provide a simple DOS (or Windows) solution, I'll just take the directory home on my jump drive and do it in Linux after work. Thanks for trying. :)
ASKER CERTIFIED SOLUTION
Avatar of ghostdog74
ghostdog74

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of damijim

ASKER

I just resolved it in Linux... but I will try your script in Windows when I get back to work and award the points if it does. Thanks.

Linux solution:
ls | perl -nle '$s="";@n=split /\./ ;@chars=('a'..'z',0..9); $s.=$chars[rand @chars] for (1..8);rename($_,lc join(".",$s,$n[$#n]));'

It doesn't account for the possibility of two randomly generated filenames being the same, but you can test before and after with ls | wc - l
Avatar of matrixnz
matrixnz

"I was thinking in PFrank, I could just use a few of the bulk renames.. like "only keep 4th and 5th char in prefix" then do like something and then some other command"

There is a freeware app Flexible Renamer that can do this http://www.snapfiles.com/get/flexrenamer.html I use it quite a bit to rename multiple files at once, very fast and includes an undo function.