mackybean

convert folder to ABS compatible (linux)

Feb 28th, 2026
220
1
Never
12
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 1 0
  1. #!/bin/bash
  2.  
  3. FFPROBE="/usr/bin/ffprobe"
  4. ROOT="."
  5.  
  6. find "$ROOT" -type f -name "*.m4b" | while read -r file; do
  7.  
  8. # Extract metadata
  9. AUTHOR=$($FFPROBE -v quiet -show_entries format_tags=composer -of default=nw=1:nk=1 "$file")
  10. SERIES=$($FFPROBE -v quiet -show_entries format_tags=SERIES -of default=nw=1:nk=1 "$file")
  11. TITLE=$($FFPROBE -v quiet -show_entries format_tags=album -of default=nw=1:nk=1 "$file")
  12.  
  13. # Fallbacks
  14. [ -z "$AUTHOR" ] && AUTHOR="Unknown Author"
  15.  
  16. # If SERIES tag missing, use original folder name
  17. if [ -z "$SERIES" ]; then
  18. SERIES="$(basename "$(dirname "$file")")"
  19. fi
  20.  
  21. [ -z "$TITLE" ] && TITLE="$(basename "$file")"
  22.  
  23. # Sanitize folder names (replace bad characters)
  24. sanitize() {
  25. echo "$1" | sed 's/[:]/ -/g'
  26. }
  27.  
  28. AUTHOR=$(sanitize "$AUTHOR")
  29. SERIES=$(sanitize "$SERIES")
  30. TITLE=$(sanitize "$TITLE")
  31.  
  32. DEST="$ROOT/$AUTHOR/$SERIES/$TITLE"
  33.  
  34. mkdir -p "$DEST"
  35.  
  36. echo "Moving:"
  37. echo " $file"
  38. echo "→ $DEST/"
  39.  
  40. mv "$file" "$DEST/"
  41.  
  42. done
  43.  
  44. echo "Done."
Advertisement
Comments
  • anewjose
    253 days
    # text 0.21 KB | 0 0
    1. Thanks.
    2. Here is powershell version for windows https://pastebin.com/q4iVDxCP
    3. Works for ebups too using Calibre and I made some other minor changes.
    4. Sorry for posting here, but I don't have an account "there".
  • User was banned
  • User was banned
    • mackybean
      220 days
      # text 0.23 KB | 0 0
      1. I've literally never been to that telegram before, however, if we've come up with similar code (not that it's all that unique, it's just using bash to rename stuff) then I'm glad that means more people are converting their libraries to ABS
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment