Recursive wildcards in Rake?

徘徊边缘 提交于 2019-12-08 05:48:49

问题


Follow up to this question about GNU make:

I've got a directory, flac, containing .FLAC files. I've got a corresponding directory, mp3 containing MP3 files. If a FLAC file is newer than the corresponding MP3 file (or the corresponding MP3 file doesn't exist), then I want to run a bunch of commands to convert the FLAC file to an MP3 file, and copy the tags across.

The kicker: I need to search the flac directory recursively, and create corresponding subdirectories in the mp3 directory. The directories and files can have spaces in the names, and are named in UTF-8.

It turns out that this won't work in make, because of the spaces in the directories and filenames, so I'm wondering how to do it in rake instead...


回答1:


The best I've come up with so far looks like this:

FLAC_FILES = FileList['flac/**/*.flac']

FLAC_FILES.each do |flac|
  mp3 = flac.pathmap("%{^flac,mp3}X.mp3")
  file mp3 => flac do
    puts "Converting #{flac} to #{mp3}"
  end
  task :default => mp3
end

Critique, anyone?



来源:https://stackoverflow.com/questions/2483418/recursive-wildcards-in-rake

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!