Closed duenni closed 9 years ago
Hi duenni, This action is meant to be run as a folder action, which is triggered when files are added to a specific folder. It looks like Automator doesn't actually pass the contents of the folder into the ruby script when you run it from Automator. I'm not sure if this behaviour is new to Yosemite.
Does it work for you when you run it as a folder action? Some tweaking would need to be done to get it to work in a different context.
Yes it works as a folder action. Ok, to run it from Automator you have to put "Get selected Finder Items" as first step for testing. This works as well. I just like to run the shell script as a Service and I also don't want to delete the FLAC file. I think this worked like a charm before....but now if I right click a FLAC file and select the Service it is instantly done and nothing happens. I double checked the homebrew path containing the flac bin.
Ok, this should work:
flac_bin = "/usr/local/bin"
ENV['PATH'] = "#{ENV['PATH']}:#{flac_bin}"
ARGF.each do |file|
file.chomp!
next unless File.extname(file) == '.flac'
export_folder = File.dirname(file)
Dir.chdir(export_folder)
system({"PATH"=>ENV['PATH']}, "flac2mp3", file)
puts export_folder + "/" + File.basename(file,'.*')+".mp3"
end
Thank you very much! Really appreciate it!
Thanks alot, but how is it now possible to adjust the quality? Set quality between "#{file}“ and `: V2, V1, V0, 320 doesn't work anymore.
system({"PATH"=>ENV['PATH']}, "flac2mp3", file, "V0")
should do it.
Wow thanks, that was fast! 320 ist still the best, right?
This page explains the differences. 320 will give you a constant 320kbps, while V0 will output a variable bitrate MP3 at around 245kbps. 320 will also increase the file size.
According to the link above, there is rarely a perceptible difference between V0, V1 and V2, and "no one has produced ABX test results demonstrating that perceived quality [of 320 CBR] is ever better than the highest VBR profiles described above".
So, if you don't mind the larger files, go with 320. Otherwise, stick with the default: V0.
Hi!
I used your workflow to generate an Automator Service for converting FLAC to MP3. It worked until Yosemite came out. I have a "Run Shell Script"-Action with the following:
And now I get the following error
dirname: no implicit conversion of nil into String (TypeError)
on lineexport_folder = File.dirname(ARGV.first)
when running this with Automator. Any idea? I am in no way a ruby expert. Thanks in advance!