Rake 中的递归通配符? [英] Recursive wildcards in Rake?

查看:54
本文介绍了Rake 中的递归通配符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跟进这个关于 GNU make 的问题:

我有一个目录 flac,其中包含 .FLAC 文件.我有一个相应的目录,mp3 包含 MP3 文件.如果 FLAC 文件比相应的 MP3 文件更新(或相应的 MP3 文件不存在),那么我想运行一堆命令将 FLAC 文件转换为 MP3 文件,并复制标签.

踢球者:我需要递归搜索flac目录,并在mp3目录下创建相应的子目录.目录和文件的名称可以有空格,以UTF-8命名.

事实证明这在 make 中不起作用,因为目录和文件名中有空格,所以我想知道如何在 rake 中做到这一点......

解决方案

目前我想到的最好的方案如下:

FLAC_FILES = FileList['flac/**/*.flac']FLAC_FILES.each 做 |flac|mp3 = flac.pathmap("%{^flac,mp3}X.mp3")文件 mp3 =>手拉手将将 #{flac} 转换为 #{mp3}"结尾任务:默认=>mp3结尾

有人批评吗?

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...

解决方案

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?

这篇关于Rake 中的递归通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆