Advertisement
ecube8

How to move only files with other equal filename but differe

Jan 30th, 2014
141
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. todir=$1
  4.  
  5. cd $( dirname $0 )
  6. DIRLIST=$( ls -F | grep '/' | tr -d '/' )
  7.  
  8. for DIR in $DIRLIST
  9. do
  10.     mp3num=$( ls $DIR | grep -c \\.mp3 )
  11.     m4anum=$( ls $DIR | grep -c \\.m4a )
  12.     filnum=$( ls $DIR | wc -l )
  13.  
  14.     echo $DIR $mp3num $mp4num $filnum
  15.  
  16.     if [ $DIR = $todir ]; then
  17.         continue
  18.     fi
  19.  
  20.     if [ $m4anum = 0 -o $mp3num = 0 ]
  21.     then
  22.         continue
  23.     elif [ $mp3num != 0 -a $m4anum != 0 ]
  24.     then
  25.         mv $DIR/*.mp3 $todir
  26.     fi
  27. done
Advertisement
RAW Paste Data Copied
Advertisement