[英]How to traverse a directory structure to find files
I am trying to create a script that will traverse through my music directory and eventually convert anything over 192bps to 192bps. 我正在尝试创建一个脚本,该脚本将遍历我的音乐目录,并最终将超过192bps的任何内容转换为192bps。 So far I have the following... 到目前为止,我有以下...
#!/bin/bash
music="/backup/MUSIC/AC-DC/Back In Black"
for file in `find "$music" -type f -name '*.mp3'`; do
echo "$file" | cut -d/ -f6-
done
but I am getting weird output , like 1 word per line, and not even the entire file name. 但我得到奇怪的输出,像每行1个单词,甚至没有整个文件名。 I don't understand what the cut -d/ -f6- is for either... 我不明白-d / -f6-是什么意思...
Any help is appreciated. 任何帮助表示赞赏。
Try using a while
loop instead: 尝试使用while
循环:
#!/bin/bash
music="/backup/MUSIC/AC-DC/Back In Black"
find "$music" -type f -name "*.mp3" | while read file; do
echo "$file"
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.