zsh-users
 help / color / mirror / code / Atom feed
* enum-files and change-ext
@ 2019-03-23 19:49 Emanuel Berg
  2019-03-23 20:02 ` Emanuel Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg @ 2019-03-23 19:49 UTC (permalink / raw)
  To: zsh-users

Hello, I just wrote this. [1]

Is it any good? :)

TIA


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

    local number=1

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

change-extention () {
    local new_extention=$1
    shift

    local -a files
    files=($@)

    for f in $files; do
        if [[ -f $f ]]; then
            mv $f ${f:r}.$new_extention
        else
            no-file-msg $f
        fi
    done
}
alias change-ext=change-extention


[1] lines 11-42 @ http://user.it.uu.se/~embe8573/conf/.zsh/files-fs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-26  5:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23 19:49 enum-files and change-ext Emanuel Berg
2019-03-23 20:02 ` Emanuel Berg
2019-03-24 17:52   ` Daniel Shahaf
2019-03-26  5:29     ` Emanuel Berg

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).