ExifTool Forum

ExifTool => Newbies => Topic started by: wout on April 05, 2018, 11:06:47 PM

Title: Randomize keyword order
Post by: wout on April 05, 2018, 11:06:47 PM
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!
Title: Re: Randomize keyword order
Post by: Phil Harvey on April 06, 2018, 07:14:02 AM
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
Title: Re: Randomize keyword order
Post by: wout on April 06, 2018, 07:58:17 PM
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!
Title: Re: Randomize keyword order
Post by: Phil Harvey on April 07, 2018, 06:30:17 AM
It worked for me.  Are you on Windows?  If not, you must change to single quotes.

- Phil
Title: Re: Randomize keyword order
Post by: wout on April 08, 2018, 12:13:52 AM
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.