Advertisement
printesoi

Append extension

May 17th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.28 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. for fisier in *; do
  4.     type=`file $fisier`;
  5.     image=`grep "image" <<< $type &>/dev/null;echo $?`;
  6.  
  7.     if [[ "$image" -eq "0" ]] ;then
  8.         ext=`echo $type| tr -s ' ' | cut -d " " -f 2 | tr [:upper:] [:lower:]`;
  9.         echo $ext;
  10.         cp "$fisier" "$fisier.$ext";
  11.     fi;
  12. done;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement