Rename a file extension to the file name in a batch file
Results 1 to 5 of 5

Thread: Rename a file extension to the file name in a batch file

  1. #1
    Join Date
    Jul 2002
    Posts
    3

    Rename a file extension to the file name in a batch file

    Hello all:

    In a batch file is there a way a person could take a file, rename the file name to its extension and then change the extension to something else? Then, following this pattern, have the changes applied to a large amount of files all at the same time?


    ex: .123 changed to 123.txt
    .987 changed to 987.txt
    .654 changed to 654.txt
    .345 changed to 345.txt
    .678 changed to 678.txt

    Thanks in advance
    Andrew

  2. #2
    Join Date
    May 2002
    Location
    London Ontario Canada
    Posts
    1,335
    It would be simple if all the files had extensions .123 but you are saying there are several combinations of numbers. I don't know of any way to do that even in DOS. Not using the example you descibe at least. In DOS a simple ren command could change all .123 files to .txt
    It would look like this: C:> ren *.123 *.txt
    So your proposed batch file would be a list of that rename command for every file extension.
    tiberiuscan

  3. #3
    Join Date
    Jul 2002
    Location
    Surf City, Florida
    Posts
    468
    I can get you almost there.

    ren *.* *.*.txt

    that will give you a three part file name and I think change the file type with all being txt files but I do not know how to strip off the first part of the file name.

    I just tried this and it seemed to work.

  4. #4
    Join Date
    Feb 2000
    Location
    Idaho Falls, Idaho, USA
    Posts
    18,423
    What version of Windows/DOS does the batch file need to run under? There are ways of doing this with batch files, but there are also much easier methods of programming this function available. If I wanted to do this, I'd use either a QBasic program or a Visual Basic program to do it.

  5. #5
    Join Date
    Jul 2002
    Posts
    3
    Hey thanks for replying.

    The ren *.* *.*.txt helped point me in the right direction.

    I'm planing to run the batch under a win2k pro enviroment.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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