Unix/Linux

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Howto : rename files dir/*.asc to dir/*.asc.sent

    7 answers - 116 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi everybody,
    How can i change several files extensions at once ?
    Thanks in advance
  • No.1 | | 401 bytes | |

    iris <lilianenb@gmail.comwrote:
    : Hi everybody,

    : How can i change several files extensions at once ?

    one way is a quick shell script, as in

    for index in `ls dir/*.asc`
    do
    mv dir/$index dir/${index}.sent
    done

    NTE- this may or may not work in your shell, depending
    upon what shell you use, but pretty much all shells
    can do somethig similar.

    Stan
  • No.2 | | 149 bytes | |

    iris wrote:
    Hi everybody,
    --
    How can i change several files extensions at once ?
    --
    Thanks in advance
    man rename
  • No.3 | | 555 bytes | |

    PGP SIGNED MESSAGE
    Hash: SHA1

    iris wrote:
    Hi everybody,
    --
    How can i change several files extensions at once ?

    Strangely enough, the utility is called "rename". See the rename(1)
    manpage for details ("man 1 rename")
    - --
    Lew Pitcher, IT Specialist, Enterprise Data Systems
    Enterprise Technology Solutions, TD Bank Financial Group

    ( expressed here are my own, not my employer's)
    PGP SIGNATURE
    Version: GnuPG v1.2.4 (MingW32)

    nxiteiNK0j48Ph6AiaILzDE=
    =XRJM
    PGP SIGNATURE
  • No.4 | | 253 bytes | |

    "iris" <lilianenb@gmail.comwrites:

    >Hi everybody,


    >How can i change several files extensions at once ?

    for i in *.asc
    do
    mv $i $i.sent
    done
  • No.5 | | 726 bytes | |

    PGP SIGNED MESSAGE
    Hash: SHA1

    Unruh wrote:
    "iris" <lilianenb@gmail.comwrites:
    >
    >Hi everybody,
    >
    >
    >How can i change several files extensions at once ?
    >
    >

    for i in *.asc
    do
    mv $i $i.sent
    done

    As I was reminded recently:

    for i in *.asc ;
    do
    mv "$i" "$i.sent"
    done

    Dont forget the quotes.

    - --
    Lew Pitcher, IT Specialist, Enterprise Data Systems
    Enterprise Technology Solutions, TD Bank Financial Group

    ( expressed here are my own, not my employer's)
    PGP SIGNATURE
    Version: GnuPG v1.2.4 (MingW32)

    wHMKcd/HN1S4TfXKQBVFI=
    =eBPQ
    PGP SIGNATURE
  • No.6 | | 571 bytes | |

    stan@worldbadminton.com did eloquently scribble:
    --
    iris <lilianenb@gmail.comwrote:
    : Hi everybody,
    --
    : How can i change several files extensions at once ?
    --
    one way is a quick shell script, as in

    for index in `ls dir/*.asc`
    do
    mv dir/$index dir/${index}.sent
    done

    NTE- this may or may not work in your shell, depending
    upon what shell you use, but pretty much all shells
    can do somethig similar.

    This can be made to work by simply putting
    #!/bin/bash
    as the first line and making the script executable.
  • No.7 | | 997 bytes | |

    2006-01-25, stan@worldbadminton.com wrote:
    iris <lilianenb@gmail.comwrote:
    >: Hi everybody,
    >
    >
    >: How can i change several files extensions at once ?
    >
    >

    one way is a quick shell script, as in

    for index in `ls dir/*.asc`

    That will break if there are spaces or other special characters in
    any of the file names.

    You don't need ls (it causes the problem):

    for index in dir/*.asc

    do
    mv dir/$index dir/${index}.sent

    This will try to move dir/dir/; dir/ is already included in
    $index.

    This will also break under the same conditions as using ls. Quote
    your variables:

    mv "$index" "${index}.sent"

    done

    NTE- this may or may not work in your shell, depending
    upon what shell you use, but pretty much all shells
    can do somethig similar.

    Written correctly, it will work in all Bourne-type shells (bash,
    ash, dash, ksh, pdksh, etc.).

Re: Howto : rename files dir/*.asc to dir/*.asc.sent


max 4000 letters.
Your nickname that display:
In order to stop the spam: 2 + 1 =
QUESTION ON "Unix/Linux"

EMSDN.COM