TheAtomicAss icon

Automated moving in Bash

TheAtomicAss | PRO | 11/26/20 11:34:56 PM UTC (Edited) | 0 ⭐ | 549 👁️ | Never ⏰ | []
text |

930 B

|

None

|

0 👍

/

0 👎

# This is a small automated move script, based on filename patterns, in Bash.
 # This comes from a larger script, so this is just a function with some hanging variables.
 cat ${moveList} |\
  while IFS='|' read i j
    do
      # The following 3 lines are for error checking
      echo -e "'$i' reads as $i"
      echo -e "'$j' reads as $j"
        find . -maxdepth 1 -type f \( -iname "$i" ! -iname "*part*" \)
        find . -maxdepth 1 -type f \( -iname "$i" ! -iname "*part*" \) -exec mv {} "$j" \; -exec echo -e "Moved {} to $j" >> $errorsFile \;
    done
  # The $moveList follows the following format:
 # Before the vertical pipe is the pattern to match, after the pipe is the location, as a relative sub-directory.
*-Adulruna-*|0.Music/Adulruna/
*-Aephanemer-*|0.Music/Aephanemer/
*-Aldious Channel-*|0.Music/Aldious/
*-Aldious Official-*|0.Music/Aldious/
*-AMR-*|0.Music/BABYMETAL/
*-Ankor Official-*|0.Music/Ankor/
 

Comments