2017-05-12 46 views
0

我正在使用findls列出子文件夹中包含的mp3文件。在每个子文件夹中,我想将包含的文件列表输出到本地文件(存储在此子文件夹中)。如何列出子文件夹中的文件并将此列表输出到本地文件?

我试过这个命令:

find . -type f -name \*.mp3 -execdir basename {} >> playlist.m3u \; 

,但它被保存在根目录.和发现MP3文件不会包含子目录写入文件playlist.m3u

有没有办法写入存储在子目录中的文件?

回答

0

尝试下面的命令,这将帮助你:

find -type d -exec bash -c 'cd $1; find -maxdepth 1 -not -name "." -name \*.mp3 -printf "%f," | awk "{print substr(\$0,0,length(\$0)-1)}" > playlist.m3u' bash "{}" \; 

这将用逗号分隔的文件列表,请相应地改变这一点。

+0

谢谢!我修改了你的命令:'find -type d -exec bash -c'cd“$ 1”; find -maxdepth 1 -name \ *。mp3 -printf“%f \ n”> playlist.m3u'bash“{}”\;' – lamayo

相关问题