#!/bin/bash

#Get all files in current directory
originalFiles=$(ls *.jpg)

# Loop through all files and do your changes
for loopFile in $originalFiles
do
  # Create your new filename including the extension
  mv $loopFile penguin$loopFile
done


#!/bin/bash
x=1
for fname in *.jpg
do
mv $fname `printf "your_desired_prefix%03d.jpg" $x`
x=$(($x+1))
done


#!/bin/bash


files=$(ls -1 | grep .jpg)

for x in $files
do
mv $x penguine$x
done



# sorted list with real file names
REALNAME="/path/to/sorted.real.names"

# list with wanted name
WANTEDNAME="/path/to/wanted.names"

# directory that holds pictures/files
PICDIR="/path/to/picture/directory"

sdiff -t ${REALNAME} ${WANTEDNAME} | \
sed 's/ [ ]*|  /|/' | \
 awk -v PICDIR=${PICDIR} -F"[.|]" '{ print "mv "PICDIR"/"$1"."$2" \""PICDIR"/"$3"."$2"\"" }' > /tmp/rename-this
. /tmp/rename-this

#sdiff -t ${REALNAME} ${WANTEDNAME} | sed 's/ [ ]*|  /|/' | \
#  awk -v PICDIR=${PICDIR} -F"[.|]" '{ print "mv "PICDIR"/"$1"."$2" \""PICDIR"/"$3"."$2"\"" }' | bash



#
#
#
exec 3<textfile1
exec 4<textfile2
cd /path/to/directory/with/images
while read file <&3; read name <&4
do
  mv "$file" "$name"
done


##illegal /
#
#
#!/bin/bash

illegal=/
replace=_

for i in $( ls *$illegal* );
do
src=$i
tgt=$(echo $i | sed -e "s/$illegal/$replace/")
mv $src $tgt
done


#
#
#
LISTFILE=filenames.txt
for i in *
do
    FILENAME=$i
    NEWFILENAME=`egrep $FILENAME $LISTFILE`

    if [ -z "$NEWFILENAME" ]
    then
        echo did not find $FILENAME in $LISTFILE
    else
        echo would mv $FILENAME $NEWFILENAME
    fi
done


#
#
#
#!/bin/bash
# copy all files in the directory to an output one renaming them
# sequentially.
#
#          GNU LESSER GENERAL PUBLIC LICENSE
#               Version 2.1, February 1999
#
# Copyright (C) 1991, 1999 Free Software Foundation, Inc.
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
#

OUT_DIR=out
PAD_LENGTH=5

if [ -z "$1" ] || [ -z "$2" ] ; then
   echo "./move.sh <number-to-start-from> <extension>"
   echo " "
   echo "./move.sh 12 JPG"
else
   # testing output directory exist. if not create it.
   if [ ! -d ${OUT_DIR} ] ; then
      mkdir ${OUT_DIR}
   fi

   COUNTER=$1
   EXT=$2

   for file in *.${EXT} ; do
      OUTFILE=$(printf "%0${PAD_LENGTH}i\n" "${COUNTER}")
      cp -v $file ${OUT_DIR}/${OUTFILE}.${EXT};
      let COUNTER++;
   done
fi


#
#3
#
find /top/dir -type f -name "*.jpg" | while read fname  #finds all files in /top/dir which end in .jpg .. can replace find with ls if all files are in same directory
do           #for each such filename
      newname=`echo "$fname" | sed 's: ::g'` #form the newname by removing all spaces .. If you need to add a prefix to filename, you can add it to newname
      mv "$fname" $newname   #rename the old file to newname that we formed above
done

##
#
#me '*.txt'| sed 's/\(.*\).txt/mv \1.txt \1.doc/'| bash

find . -name '*.txt'| sed 's/\(.*\).txt/mv \1.txt \1.doc/'| bash





