Advertisement
TheAtomicAss

Automated moving in Bash

Nov 26th, 2020 (edited)
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. # This is a small automated move script, based on filename patterns, in Bash.
  2.  
  3. # This comes from a larger script, so this is just a function with some hanging variables.
  4.  
  5. cat ${moveList} |\
  6. while IFS='|' read i j
  7. do
  8. # The following 3 lines are for error checking
  9. echo -e "'$i' reads as $i"
  10. echo -e "'$j' reads as $j"
  11. find . -maxdepth 1 -type f \( -iname "$i" ! -iname "*part*" \)
  12. find . -maxdepth 1 -type f \( -iname "$i" ! -iname "*part*" \) -exec mv {} "$j" \; -exec echo -e "Moved {} to $j" >> $errorsFile \;
  13. done
  14.  
  15.  
  16. # The $moveList follows the following format:
  17.  
  18. # Before the vertical pipe is the pattern to match, after the pipe is the location, as a relative sub-directory.
  19. *-Adulruna-*|0.Music/Adulruna/
  20. *-Aephanemer-*|0.Music/Aephanemer/
  21. *-Aldious Channel-*|0.Music/Aldious/
  22. *-Aldious Official-*|0.Music/Aldious/
  23. *-AMR-*|0.Music/BABYMETAL/
  24. *-Ankor Official-*|0.Music/Ankor/
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement