News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Randomize keyword order

Started by wout, April 05, 2018, 11:06:47 PM

Previous topic - Next topic

wout

Hello,

I was wondering if there is a way to take the existing keywords of a (JPG) file and randomize their order.

I wish the keyword order is no longer alphabetical but random.

Would this be possible with exiftool?

Thanks!

Phil Harvey

Sure.  This could more easily be done with a user-defined Composite tag, but as a one-liner:

exiftool "-keywords<${keywords;my @a=split m(//);my @b;push @b, splice(@a,int(rand(@a)),1) while @a;$_=\@b}" -sep // FILE

Use Subject instead of Keywords if you are using XMP keywords instead of IPTC/NAA.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wout

Hi Phil,

Thanks so much for your time!

I tried the script in various ways but I get a 'bad substitution' return. Does it work on your end?

P.S. I have already successfully run exiftool "-Title>Description", but that is a much simpler code!

Phil Harvey

It worked for me.  Are you on Windows?  If not, you must change to single quotes.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wout

It works with the single quotes! I'm on mac indeed. So happy. Thanks for all the work you put into this software, it really helps to organise my files.