[Linux]Script to randomize imagenames.

All non-XnView related: softwares, formats, imaging, photography...

Moderators: XnTriq, helmut, xnview

marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

[Linux]Script to randomize imagenames.

Post by marsh »

I formed this script to randomize filenames. It prefixes the original name with a different number. Perhaps it will be generally useful when used with 'open with' from file manager.
A typical result: 3192920088_originalname

Code: Select all

#!/bin/sh
#
# Randomize filenames of images in folder
#
for i in "$*"
do
    folder=`dirname "$i"`
    cd $folder
for i in ./*.jpg
do
   mixed="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" " )"
   orig=`basename "$i" .jpg`
   mv "$i" "$mixed"_"$orig".jpg
done
for i in ./*.png
do
   mixed="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" " )"
   orig=`basename "$i" .png`
   mv "$i" "$mixed"_"$orig".png
done
for i in ./*.gif
do
   mixed="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" " )"
   orig=`basename "$i" .gif`
   mv "$i" "$mixed"_"$orig".gif
done
for i in ./*.tif
do
   mixed="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" " )"
   orig=`basename "$i" .tif`
   mv "$i" "$mixed"_"$orig".tif
done
done