Sorting downloads folder with bash script

Posted by Marek on Super User See other posts from Super User or by Marek
Published on 2011-10-02T18:29:11Z Indexed on 2012/10/02 15:42 UTC
Read the original article Hit count: 280

Filed under:
|

I'm writing script for my own needs to sort Downloads folder on my mac in bash. I pass to the function parameters: source directory, destination directory and array of file extensions I want to move. My problem is that when function is in "find" line then it copies just one file with that extension but when I remove all variables and I put parameters directly then it works fine. What's going on ?

 function moveFaster(){
   clear
    src=$1
    dst=$2
    typ=$3
    if [ ! -d $dst ]
      then
        mkdir $dst
      fi

    for i in "${typ[@]}"
      do
        find $src -name "${i}" -exec mv {} ${dst} \;
      done


  }

© Super User or respective owner

Related posts about bash

Related posts about shell