#!/bin/bash # johnmeister.com/linux 8 May 2019 # renaming mp3 files so they play randomly # mount /dev/sdb1 /home/luser/a # variable Y will be the mp3 filenames # variable X will be a random number between 1 and 999 # (the BASH shell variable $RANDOM worked on the command line but expressed "0" in a script) # executed the mv-B.txt as a script using "sudo mv /home/luser/b/mv-B.txt /home/luser/a/rename-script.sh ; sh ./rename-script.sh " # checked the files on the mounted thumbdrive and unmounted: sudo umount /dev/sdb1 # cd /home/luser/a/ for Y in `ls` do echo "mv $Y " >> /home/luser/b/mv-A.txt X=`perl -e 'print int rand 1000, "\n"; '` echo $X >> /home/luser/b/mv-rand.txt echo "mv $Y $X-$Y" >>/home/luser/b/mv-B.txt done