Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

mp3-cleanup 790B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env ruby
  2. # delete all but music files recursively
  3. require 'set'
  4. doDelete = ARGV.include? "--delete"
  5. verbose = ARGV.include? "-v"
  6. if doDelete
  7. puts "Will delete"
  8. end
  9. files = Dir['**/*']
  10. musicExts = ['mp3', 'mp4', 'ogg', 'm4a', 'wav', 'wma', 'mpc', 'flac']
  11. found = Hash[]
  12. files.each do |file|
  13. ext = File.extname(file).downcase[1..-1]
  14. if not File.directory? file and not musicExts.include? ext
  15. puts file if verbose
  16. if found.include? ext
  17. found[ext] << file
  18. else
  19. found[ext] = [file]
  20. end
  21. end
  22. end
  23. puts "------------------------------------------"
  24. found.each do |ext, files|
  25. puts "%s -> %d files" % [ext, files.count]
  26. if doDelete
  27. files.each do |file|
  28. puts "delete %s" % file
  29. File.unlink file
  30. end
  31. end
  32. end
  33. # puts found