Results 1 to 5 of 5

Thread: batch rename help

  1. #1
    Join Date
    Mar 2006
    Beans
    4,373
    Distro
    Ubuntu Development Release

    batch rename help

    I have a directory with a bunch of text files with only the file names ( no extension ) . I need to add a .txt extension to every file . what is the best way to do this ?
    if it ain't broke you haven't tweaked it enough

  2. #2
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,636
    Distro
    Ubuntu

    Re: batch rename help

    Assuming all the files in the directory have no extension and all the files want one

    In the directory that contains the files

    Code:
    for f in *; do mv "$f" "$f".txt; done
    If you mean only some of the files then you will need the test ( [[ ) command first.

  3. #3
    Join Date
    Mar 2006
    Beans
    4,373
    Distro
    Ubuntu Development Release

    Re: batch rename help

    that did it . Thank You
    if it ain't broke you haven't tweaked it enough

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: batch rename help

    EDIT: D'oh! nothingspecial beat me to it!

    If you are looking for a GUI tool, then check out:
    • thunar (file manager)
    • gprename
    • gnome-commander (file manager)
    • purrr
    • pyrenamer
    • gwenrename
    • krename


    In the CLI there are many ways. On Debian and Ubuntu I'd probably use the Perl based rename command.

    Code:
    cd path/to/dir/where/the/files/are
    prename -n 's/(.*)/$1.txt/' ./*
    -n tells to prename to only print the file names which would have been renamed.

    But you can use the rename command from the util-linux package, mmv or you can write your own little script.

  5. #5
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,636
    Distro
    Ubuntu

    Re: batch rename help

    Quote Originally Posted by sisco311 View Post
    edit: D'oh! Nothingspecial beat me to it!
    celebration.gif

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •