I'm currently trying to write a little script to convert all the flac files to mp3 files. However, I ran into a bit of a problem when trying to set up recursion down into all my music folders - the script kept looping into the current directory (.)Here's what I currently have:#!/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 createDirectory {    #recreate directory structure in Music folder    curDir=$pwd    newDir=${curDir/originalFLAC/Music}    mkdir -p $newDir}function convertFLAC {    #convert each flac file in current directory into an mp3 file    for FILE in $(find . -maxdepth 1 -type f); do #loop through all regular (non-directory) files in current directory        if [ ${FILE: -5} == .flac ]; then #if FILE has extension .flac            ffmpeg -i $FILE -ab 320k -map_metadata 0 ${FILE%.*}.mp3; #convert to .mp3            mv -u ${FILE%.*}.mp3 $newDir        else #copy all other files to new directory as-is            cp -ur $FILE $newDir        fi    done}enterDIRThis script is pretty clunky, since I only just started dipping into Bash. The problem (or at least where I think it is) comes from the if [ $DIR == . ]; then line - looking at my output when running the script, it doesn't seem to filter it.How do I filter out (ignore) the current directory?
How can I filter out current directory ('.') in bash?
bash;files;scripting
You can filter it in find by using -mindepth option. Like this:function enterDIR {    find . -mindepth 1-maxdepth 1 -type d | while read DIR ;     do         #recurse into every directory below top-level directory        cd $DIR/        enterDIR    done    createDirectory    convertFLAC}But the whole script doesn't look like a good solution.If I understand your idea correct, you want to walk through the whole directory tree, create there new directory, convert flac to mp3 if any and copy all non-flac files to a new dir. I would do that this way:find . -mindepth 1 -type -d -exec mkdir -p {}/originalFLAC/Music \+find . -type f -iname *.flac -exec ffmpeg -i {} -ab 320k -map_metadata 0 {}.mp3 \;find . -type f ! -iname *.flac | while read file ; do cp -v $file $(dirname $file)/originalFLAC/Music/ ; done