Skip to content

Instantly share code, notes, and snippets.

@cattleguard
Created January 3, 2018 01:11
Show Gist options
  • Save cattleguard/714661ad0516f22d4f6dcfac522d3262 to your computer and use it in GitHub Desktop.
Save cattleguard/714661ad0516f22d4f6dcfac522d3262 to your computer and use it in GitHub Desktop.
script leverages sox (Sound eXchange) to speed up most podcasts in itunes directory
#!/usr/local/bin/ruby
# Must have ruby later ruby to use Dir.children()
require 'date'
require 'shellwords'
origin_folder = '~/Music/iTunes/iTunes Media/Podcasts/'
Dir.chdir(File.expand_path(origin_folder))
contents = Dir.glob('*')
contents.each {|folder|
podcasts = Dir.children(folder)
podcasts.each {|podcast|
if File.expand_path(origin_folder + folder) == File.dirname(File.expand_path(origin_folder+folder+"/"+podcast))
if folder.downcase =~ /.*spanish.*/
else
made_on = File.mtime(File.expand_path(origin_folder+folder+"/"+podcast))
if made_on.to_date == Time.now.to_date
puts(podcast + " was made today and is getting converted")
system("sox " + File.expand_path(origin_folder+folder+"/"+podcast).shellescape + " " + File.expand_path(origin_folder+folder+"/"+ "xfaster " + podcast).shellescape + " " + "tempo 1.25")
system("mv " + File.expand_path(origin_folder + folder + "/" + "xfaster " + podcast).shellescape + " " + File.expand_path(origin_folder+folder+"/"+podcast).shellescape )
end
end
else
puts("compared " + origin_folder + "/" + folder + " to " + File.dirname(File.expand_path(origin_folder+folder+"/"+podcast)))
end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment