I am working on a program to download video from YouTube, convert it to MP3 and create a directory structure for files.
My code is:
FileUtils.cd("#{$musicdir}/#{$folder}") do YoutubeDlhelperLibs::Downloader.get($url) if File.exists?('*.mp4') puts 'Remove unneeded tempfile' Dir['*.mp4'].each do |waste| File.delete(waste) end else puts 'Temporary file already deleted' end Dir['*.m4a'].each do |rip| rip.to_s rip.split puts 'Inside the function' puts rip end end
The first goes to the already created music folder. Inside I execute get . After that, I have two files in the directory: "xyz.mp4" and "xyz.m4a".
I would like to get the file name without the extension so that I can handle both files differently.
I use an array, but the array for one match sounds crazy to me.
Is there another idea?
ruby file
Sascha Manns Dec 27 '13 at 0:41 2013-12-27 00:41
source share