Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: enum-files and change-ext



This seems to do better... so far.

#! /bin/zsh

# This file: http://user.it.uu.se/~embe8573/conf/.zsh/files-fs

enumerate-files () {
    local -a files
    files=($@)

    local number=1
    local new_name
    local ext

    for f in $files; do
        if [[ -f $f ]]; then
            ext=${f:e}
            [[ $ext ]] && ext=.$ext
            new_name=$number$ext
            if [[ -f $new_name ]]; then
                files+=($f)
            else
                mv $f $new_name
            fi
            number=$(( $number + 1 ))
        else
            no-file-msg $f # http://user.it.uu.se/~embe8573/conf/.zsh/error
        fi
    done
}

-- 
underground experts united
http://user.it.uu.se/~embe8573



Messages sorted by: Reverse Date, Date, Thread, Author