useful shell scripts

hier werde ich einige nützliche shellscripts oder tolle konsolenbefehle reinstellen..

my favourite terminalcommand 'Katzeklo' 


  cat datei | wc -l    #zählt die zeilen der datei



You have a digicam and it sorts the pictures from each day into one directory.
Now you want to number them and name them related to the day they were taken:


 #!/bin/bash

 datei=`ls IMG*.JPG | head -n 1`   #take first picture
and look 
                                   #which date it was taken
 datum=`exiftool -d %Y-%m-%d -DateTimeOriginal -S -s $datei`  

 tag='tag'   #tag it e.g. 'Berlinbilder'

 count () {    #see if there are already renamed pictures 

               #and if yes, count them
           ls 2011*.JPG | wc -l
          }


 a=`count`
 let a=a+1   #start numbering the other pictures 

             #with the next number

 for i in `ls IMG*.JPG`;   #do the follwing for all 

                           #items IMG*.JPG in directory
  do
    #rename ictures in same format yyyy-mm-dd_###_tag.JPG
    if [ $a -lt 10 ]
    then mv $i $datum'_'00$a'_'$tag.JPG
    elif [ $a -ge 10 ]
    then mv $i $datum'_'0$a'_'$tag.JPG
    else [ $a -ge 100 ]
    mv $i $datum'_'$a'_'$tag.JPG
    fi
    let a=a+1
    echo 'bild '$a
  done


 pfad=`pwd` #rename directory the same way
 cd ..
 mv $pfad $datum'_'$tag

  echo "Fertig"   #and finally done ;-)



Usefull command to get rid of the annoying spaces windoofs user use:


 for i in *\ *;do mv "$i" "${i// /_}";done



You forgot to synchronise your cameras? Fix it:


 exiftool -P -alldates-='0:0:0 0:4:0' -overwrite_original bild.jpg

 #minus 4minutes
 #syntax: 'y:w:d h:m:s'
 #plus time: +=



Easily resize your pictures (for web use):


 convert -resize 1000 original.jpg resized.jpg   

 #number defines pixels



Downloading all files of a certain type from a website
(e.g. someone shares pictures by uploading them an sending you the site with all the single links):


 wget -r -A.JPG www.example.of/bilder/



To start a terminal command at a certain time, e.g. at 4pm:


 at teatime
    command
 #press ctrl+D



Convert *.eps files to *.fig to manipulate them using xfig


  pstoedit -f fig input.eps > output.fig