find rename in Linux - Unix

This is a discussion on find rename in Linux - Unix ; I'm using Debian Lenny and want to rename some files to add a dot just before the file extension so that the abcdefmht become abcdef.mht I tried this: find . -name '*.mht' -exec rename 's/*mht/*\.mht/' '{}' \; but it fails. ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: find rename in Linux

  1. find rename in Linux

    I'm using Debian Lenny and want to rename
    some files to add a dot just before the file extension
    so that the abcdefmht become abcdef.mht

    I tried this:
    find . -name '*.mht' -exec rename 's/*mht/*\.mht/' '{}' \;

    but it fails.

    What am i doing wrong?

    Thanks
    CJ

  2. Re: find rename in Linux

    2008-06-8, 11:14(-07), Citizen Jimserac:
    > I'm using Debian Lenny and want to rename
    > some files to add a dot just before the file extension
    > so that the abcdefmht become abcdef.mht
    >
    > I tried this:
    > find . -name '*.mht' -exec rename 's/*mht/*\.mht/' '{}' \;
    >
    > but it fails.

    [...]

    find . -name '*[!.]mht' -exec sh -c '
    mv -i "${1%mht}" "${1%mht}.mht"' {} {} \;

    With zsh:

    autoload -U zmv
    alias zmv+='noglob zmv -W'
    # those previous lines typically in ~/.zshrc

    zmv+ **/*[^.]mht **/*[^.].mht

    --
    Stéphane

+ Reply to Thread