Automator action for generating a random folder name

Discussion in 'macOS' started by feuerschlange, Jul 13, 2009.

  1. feuerschlange macrumors regular

    Oct 13, 2008
    I want to host photographs on a website, where I need a Automator action, that generates random filenames (i.e. filename of 8 random numbers).

    I want to create a Automator script for exporting photographs from Lightroom and uploading them within their automatically created random named folders.

    Any ideas, how to generate random folder names?
  2. feuerschlange thread starter macrumors regular

    Oct 13, 2008
    Thanks for posting - too bad, it doesn't help for the issue.
    I need something, that can be used in an workflow (a tip with using automators "random variable function" for renaming a folder for example). An seperate app, that creates a random number and renames a file with it would be most useful too, as I could use this within automator too.
  3. pcwiz macrumors member

    May 28, 2008
    There's a shell command I know that generates random strings:

    openssl rand -base64 8

    Change 8 at the end to whatever you want the length of the random string to be. I know theres a "Run Shell Script" automator action so you can use this and then pipe the output to whatever action you are using to name the folders
  4. feuerschlange thread starter macrumors regular

    Oct 13, 2008
    Mmmh - I tried it and have two issues:

    -the shell command gives random signs (what should I change, to output only numbers?)

    -it seems, that the output of the "Run Shell Script" command in automator creates a variable, that can not be used, to rename a file.

    Looks like a dead end so far.

    There is a Automator variable called "random number", which creates a variable and can also not be used.
  5. miles01110 macrumors Core


    Jul 24, 2006
    The Ivory Tower (I'm not coming down)
    Does it have to be Automator? Name Mangler is a much better renaming tool. The "Advanced" mode might have something for you.
  6. mysterytramp macrumors 65816


    Jul 17, 2008
    Or even just write an AppleScript. It'll give you more control over what you're trying to do.

  7. belvdr macrumors 603

    Aug 15, 2005
    No longer logging into MR
    Check the Automator Programming Guide to see if there's something that can be done with the shell.

    If so, try either of these two:

    openssl rand -hex 4
    mktemp -d /path/to/www/XXXXXXXX
    The second one will create a folder under /path/to/www with 8 random characters and will do so safely (i.e. it will not create a directory with the same name). After creating it, it will output the name of the newly created directory as well. I recommend the latter.

Share This Page