Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. iTunes/Music/${author}/${album}/${song.mp3}
  2.  
  3. #!/bin/bash
  4. SAVEIFS=$IFS
  5. IFS=$(echo -en "nb")
  6. for f in *.mp3
  7. do
  8. lame --cbr $f __out.mp3
  9. mv __out.mp3 $f
  10. done
  11. IFS=$SAVEIFS
  12.  
  13. $ cd iTunes/Music
  14. $ global normalize_mp3.sh
  15.  
  16. global() {
  17. shopt -s globstar
  18. origdir="$PWD"
  19. for i in **/; do
  20. cd "$i"
  21. echo -n "${PWD}: "
  22. eval "$@"
  23. echo
  24. cd "$origdir"
  25. done
  26. }
  27.  
  28. global normalize_mp3.sh
  29.  
  30. $ echo $BASH_VERSION
  31. 4.1.5(1)-release
  32. $ cd /var
  33. $ tree -d | head
  34. .
  35. ├── backups
  36. ├── cache
  37. │   ├── apt
  38. │   │   ├── apt-file
  39. │   │   └── archives
  40. │   │   └── partial
  41. │   ├── cups
  42. │   │   └── rss
  43. │   ├── debconf
  44. $ global 'echo -n This command is executed in $PWD at $(date); sleep 1'
  45. /var/backups: This command is executed in /var/backups at Mo 1. Jul 12:11:00 CEST 2013
  46. /var/cache: This command is executed in /var/cache at Mo 1. Jul 12:11:01 CEST 2013
  47. /var/cache/apt: This command is executed in /var/cache/apt at Mo 1. Jul 12:11:02 CEST 2013
  48. /var/cache/apt/apt-file: This command is executed in /var/cache/apt/apt-file at Mo 1. Jul 12:11:03 CEST 2013
  49. /var/cache/apt/archives: This command is executed in /var/cache/apt/archives at Mo 1. Jul 12:11:04 CEST 2013
  50. /var/cache/apt/archives/partial: This command is executed in /var/cache/apt/archives/partial at Mo 1. Jul 12:11:05 CEST 2013
  51. /var/cache/cups: This command is executed in /var/cache/cups at Mo 1. Jul 12:11:07 CEST 2013
  52. /var/cache/cups/rss: This command is executed in /var/cache/cups/rss at Mo 1. Jul 12:11:08 CEST 2013
  53. /var/cache/debconf: This command is executed in /var/cache/debconf at Mo 1. Jul 12:11:09 CEST 2013
  54. ...
  55.  
  56. find ~/Music -name *.mp3 | while IFS= read -r f; do
  57. lame --cbr "$f" "$f"_temp
  58. mv "$f"_temp "$f"
  59. done
  60.  
  61. mdfind 'kMDItemAudioBitRate>128000' -onlyin ~/Music |
  62. parallel lame --cbr {} {}_temp ; mv {}_temp {}
  63.  
  64. f() { lame --cbr "$1" "$1"_temp; mv "$1"_temp "$1"; }
  65. export -f f
  66. mdfind 'kMDItemAudioBitRate>128000' -onlyin ~/Music | parallel f
  67.  
  68. shopt -s globstar # bash 4.0 or later
  69. for f in ~/Music/**/*.mp3; do lame --cbr "$f" "$f"_temp; mv "$f"_temp "$f"; done
  70.  
  71. #!/bin/bash
  72. # first cd to iTunes/Music
  73. for f in */*/*.mp3
  74. do
  75. lame --cbr "$f" __out.mp3 && mv __out.mp3 "$f"
  76. done
  77.  
  78. #! /usr/bin/env bash
  79. for f do
  80. lame --cbr "$f" "$f_out.mp3"
  81. mv "$f_out.mp3" "$f"
  82. done
  83.  
  84. downrate_mp3 ./*.mp3
  85.  
  86. shopt -s globstar
  87. downrate_mp3 ./**/*.mp3
  88.  
  89. find iTunes/Music -type f -name '*.mp3' -exec downrate_mp3 {} +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement