How to batch rename files with a random name??

Discussion in 'macOS' started by amiskwia, Apr 30, 2008.

  1. amiskwia macrumors newbie

    Joined:
    Nov 1, 2007
    Location:
    Seville - Spain
    #1
    Hello everybody!!! Here is my situation:
    I have a digital photo frame to see my pictures, but it only plays photos secuencially, it can't be set on "shuffle". So if I could rename the photos with random names, then the effect would be the same, as I would be seeing them in "shuffle".
    I know automator can rename files, and there are many many apps that also rename, but I haven't found one that can give the files a random name!
    Any suggestions??
    Thank you.
     
  2. MurphyM macrumors 6502

    Joined:
    Dec 29, 2007
    #2
    I needed to do the same thing for the same exact reason. I made this shell script that did it but it must have messed up resource forks or something because it broke all my jpg files! (I had copies)

    Anyway, if you have access to Windows this is a really easy way to do it:
    http://www.winsite.com/bin/Info?2000000035423

    It's called renamer.exe and it can add a random number to file names in a batch.
     
  3. riscy macrumors 6502a

    riscy

    Joined:
    Jan 4, 2008
    Location:
    China
    #3
    Image Well does this - it has a little icon in the top left corner for creating random file names. But I don't think it does batch.

    You can find it here

    NameMangler does do batch renaming and I think there is probably an advanced option where you could randomise the names (although I have never tried to do it), the link can be found on the site in my sig.
     
  4. amiskwia thread starter macrumors newbie

    Joined:
    Nov 1, 2007
    Location:
    Seville - Spain
    #4
    Hi! I am currently using renamer.exe through VMWare, until I can find a mac app that does the same. Thanks!

    I tried NameMangler, but could not find any random name option :(
     
  5. riscy macrumors 6502a

    riscy

    Joined:
    Jan 4, 2008
    Location:
    China
    #5
    If you click at the top and change to advanced, you have an option to do some coding there, so I am sure you could look at the example scripts given, but that is too technical for me, sorry and maybe also look for a NameMagler forum or contact the author, I am sure it is possible as it is a great app.
     
  6. Gordy macrumors 6502a

    Joined:
    May 22, 2005
    Location:
    Bristol, UK
  7. WilWheaton macrumors member

    Joined:
    Feb 21, 2008
    #7
    If you're ok with pasting something into the command line do this

    Code:
    for i in *.jpg; do mv $i $RANDOM.jpg; done
    just open the terminal, drag your folder in to the terminal window to change the active directory in the terminal, and paste that in press enter.
     
  8. amiskwia thread starter macrumors newbie

    Joined:
    Nov 1, 2007
    Location:
    Seville - Spain
    #8
    Thanks for the tip, but I'm looking for a free solution.

    I open a terminal window, drag the folder inside, paste that code and press enter. I get the error:

    -bash: syntax error near unexpected token `do'

    I have no clue how to use terminal commands, so I don't know what's wrong.
    Thanks for the help.
     
  9. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #9
    In Terminal first type
    Code:
    cd 
    (space after 'cd')
    THEN drag your directory to the Terminal window and press return. That will change to your image directory. Then paste
    Code:
    for i in *.jpg; do mv $i $RANDOM.jpg; done
    just like Wil said.
    I just tried it and it works as you'd expect.
     
  10. amiskwia thread starter macrumors newbie

    Joined:
    Nov 1, 2007
    Location:
    Seville - Spain
    #10
    Now it worked. With the cd space thing and I had to type JPG in capital leters for it to work, because all my pics extension are .JPG and not .jpg

    Now I'll investigate a bit and see if I can put this into an automator workflow or an applescript or something.

    Thank you very much for all the help.
     
  11. WilWheaton macrumors member

    Joined:
    Feb 21, 2008
    #11
    Thanks for dropping the ball I left there Darth.Titan, and I'm glad you got it to work amiskwia :D
     
  12. clindner macrumors regular

    Joined:
    Nov 2, 2006
    #12
    So, this is a handy one line script, but what happens if the RANDOM number generated is the same as one previously generated. Will the previous file be overwritten, or will the old file retain its current name?
     
  13. Tumbleweed666 macrumors 68000

    Joined:
    Mar 20, 2009
    Location:
    Near London, UK.
    #13
    Waking this thread up as I have the same requirement and hoping someone good at scripts cam answer this;.

    The above script works only for a single directory level (I just tried it) and though there is the issue of what happens if the random name is the same presumably that can be managed with an 'if not exists' or whatever the equivalent is for Mac, but I have an additional requirement that I am hoping a script 'whiz' can come up with an easy answer for.

    If the original files are in a more complex directory structure than a single level , the script doesnt work, it doesn't rename files in "sub folders". What I need is to copy all the files into a 'flat' directory structure and rename.
    Example, starting with;

    Top Folder
    >Folder A
    >>File01
    >>File02
    >>>Folder B
    >>>>File03
    >> Folder C
    >>> File 5
    > Folder D
    etc

    I'd like to get to
    Top Folder
    random file name 1
    random file name 2
    random file name 3
    etc

    It doesn't matter if the original folders are left around empty.

    Anyone care to have a go at a script?

    I have a similar conversation over here so best to reply there should anyone be so inclined as to reply. Thanks.
     
  14. codenewbie macrumors newbie

    Joined:
    Aug 11, 2009
    #14
    Where does this output to?

    Sorry to re-ignite a thread from some time ago, but trying to use the code suggested and unsure whether the code is executing, or if so, where it is placing the output.

    I have navigated through to the folder in which the files to rename are located. I am then using:

    for i in *.jpg; do mv $i $RANDOM.jpg; done

    as suggested by Wil. This leads to a repeated screen display of:

    usage: mv [-f | -i | -n] [-v] source target
    mv [-f | -i | -n] [-v] source ... directory

    I have not been able to identify any output from the process in the directory.

    If I change the file extension I get a message to say file not found, so the issue does not appear to be identification of files.

    Sure this is a simple fix, but no idea where to start. Can anyone help?

    Thanks
     
  15. cekim macrumors newbie

    Joined:
    May 2, 2008
    #15
  16. Dybbuk macrumors 6502a

    Joined:
    Aug 8, 2006
    #16
  17. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #17
    What OS does have it built-in?
     
  18. belvdr macrumors 601

    Joined:
    Aug 15, 2005
    #18
    It is and it's called Terminal. Learn those commands and you can do practically anything you wish.

    I don't know of _any_ OS that has a program that automatically does this.
     
  19. rodman109110 macrumors 6502

    Joined:
    Jun 7, 2007
    #19
    This site offers some services and automations. the have a rename selected files service that will do what you want i think.

    the attachment shows how it will look when installed. you just select the items you want renamed, right click, and go down to Services and than over to Disk item - Rename selected items and there will be some options to rename the files.

    http://www.macosxautomation.com/services/download/index.html
     

    Attached Files:

  20. cekim macrumors newbie

    Joined:
    May 2, 2008
  21. Hyter macrumors newbie

    Joined:
    Jan 24, 2010
    #21
    It unfortunately does overwrite files because I am having this problem. :-/
    Does anyone know of an Applescript to check to make sure it doesn't overwrite?
     
  22. enberg macrumors regular

    Joined:
    Jan 13, 2010
    #22
    Code:
    for i in *.jpg; do mv $i `od -An -N2 -i /dev/random`.jpg; done
    note that those are grave accents, not apostrophes.
     
  23. hackthatphone macrumors 68000

    hackthatphone

    Joined:
    Jul 28, 2010
    #23

    $25 for this application is OUTRAGEOUS !!!!!!!!!!!!

    I'd happily purchase this application for a REASONABLE price.

    It's greedy developers like this that make me glad a simple command line solution was presented. It's no wonder people rip off programs. You developers are just shooting yourselves in the foot.
     
  24. gwestcott macrumors newbie

    Joined:
    Jan 3, 2010
    #24
    I think the price of that application is VERY reasonable. In the way past, everything was hundreds of dollars. I think $25 is very affordable. These days we are so spoiled by the low prices that we don't appreciate when something is so inexpensive. We need to support those people who work hard at making them. They are not trying to rip us off. They are just trying to make a living.
     
  25. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #25
    I don't think it's so much the price itself, but the fact that there are free apps can do the same thing.
     

Share This Page