Advertisement
almo2001

Bash to remove some files

Jul 31st, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1.     for ext in bundle text unity3d audio tx2d; do
  2.       echo "EXT: $ext"
  3.  
  4.       for file in $(find $DIR_A -name "*$ext" | sort); do
  5.  
  6.         matcher=$(echo $file | sed s#\.[0-9]*\.$ext\$##)
  7.         matcher="$matcher.*.$ext"
  8.  
  9.         siblings=$(find $DIR_A -wholename "$matcher" | sort)
  10.  
  11.         removeList=($siblings)
  12.         unset removeList[${#removeList[@]}-1]
  13.  
  14.         if [ ! -z "$removeList" ]; then
  15.           echo "File: $file"
  16.           for remove in "${removeList[@]}"; do
  17.             echo "  Remove: $remove"
  18.             rm $remove
  19.           done
  20.         fi
  21.       done
  22.     done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement