Find the answer to your Linux question:
Results 1 to 2 of 2
Hello. From a terminal window, I would like to add an extension to a big group of files. Example... file0.ext file1.ext file2.ext file3.ext I want to add another extension to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2004
    Posts
    1

    Adding extensions to files


    Hello.

    From a terminal window, I would like to add an extension to a big group of files.

    Example...
    file0.ext
    file1.ext
    file2.ext
    file3.ext

    I want to add another extension to these files to get something like
    file0.ext.ext
    file1.ext.ext
    file2.ext.ext
    file3.ext.ext

    I have a lot of files, so I really do not want to have to cp each individual file.

    Is there a shortcut for what I want to do?

    Thanks for the help.

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    You can write a shell script to do this for you. Basically you want a for loop to iterate through the contents of the directory, checking for the extension. Then have it either skip if it's not of the right extension or do a 'mv' if it's the correct extension.

    I'm not knowledgeable in BASH, so you'll have to figure out how to implement that or someone else might be able to write it up.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

Posting Permissions

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