小编ana*_*aso的帖子

如何在 bash 中过滤掉当前目录('.')?

我目前正在尝试编写一个小脚本来将所有 flac 文件转换为 mp3 文件。然而,当我尝试在所有音乐文件夹中设置递归时,我遇到了一些问题 - 脚本不断循环到当前目录 (.)

这是我目前拥有的:

#!/bin/bash

#---
# flacToMp3: Converts FLAC files in my originalFLAC folder into mp3 files
#            and places them in an identical folder structure in my Music
#            folder.
#---

function enterDIR {
    for DIR in "$(find . -maxdepth 1 -type d)"; do #recurse into every directory below top-level directory
        if [ "$DIR" == "." ]; then  #avoid current directory infinite loop
            continue
        fi
        cd "$DIR/"
        enterDIR
    done

    createDirectory
    convertFLAC
}

function …
Run Code Online (Sandbox Code Playgroud)

scripting bash files

0
推荐指数
1
解决办法
1115
查看次数

标签 统计

bash ×1

files ×1

scripting ×1