Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Spokane, Washington, USA
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Rename all files in folder to add .doc extension (XP Pro, SP2)

    My law firm still has old legacy files on the server that date from the time we were still using Word Perfect 5.2. Unfortunately, all of these files used the 3 character extension as a part of the file name itself, not as an identifier of the program which created the files. Therefore, I must have Word set to view all files or these don't appear in the open dialogue. This isn't a huge inconvenience in Word, as I've long ago adjusted to checking that setting in the open dialogue box. However, I use Copernic as my desktop search program, and since the extensions are random, and usually don't match any known program extension, none of these files have ever made it into their index.

    Is there any way to automate adding a ".doc" extension onto these old folders full of Word Perfect files? Can I do this from Windows Explorer, or do I need to dig back into the dim recesses of my memory and try to construct a batch file? I don't want to change the existing extension, just add .doc to the end so that Copernic can index these files Word can see them without having to change the view setting in the open dialogue every time I start Word.
    Samantha

    Everything in excess! To enjoy the flavor of life, take big bites. Moderation is for monks!
    Robert A. Heinlein - Time Enough for Love

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Rename all files in folder to add .doc extension (XP Pro, SP2)

    There is no doubt a way to do this in a batch file, but I'm a MS Office user so I tend to use VBA for everything. You can run the following macro from Word (or any other Office application):

    Sub AddDocExtension()
    ' Modify as needed, but keep trailing backslash
    Const strPath = "Cocs"

    Dim strFile As String

    On Error GoTo ErrHandler

    strFile = Dir(strPath & "*.*")
    ' Loop through files in folder
    Do While Not strFile = ""
    ' Check extension
    If Not LCase(Right(strFile, 4)) = ".doc" Then
    ' Rename the file
    Name strPath & strFile As strPath & strFile & ".doc"
    End If
    ' Go on to the next one
    strFile = Dir
    Loop

    ExitHandler:
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    Modify the path as needed, and make sure that there are no other files in the folder - EVERY file in the specified folder whose name doesn't end in .doc will be renamed.

  3. #3
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Rename all files in folder to add .doc extension (XP Pro, SP2)

    Download, install and use <img src=/S/free.gif border=0 alt=free width=30 height=15> THE Rename utility.

    With little effort you can add extension to a lot of files.

  4. #4
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Rename all files in folder to add .doc extensi

    Just to make sure, copy all the files into a temporary directory (say cerfect).

    Go into a Command Prompt window.
    Type CD C:Perfect and press Enter, and ensure that's now what the prompt says.
    Type DIR and press Enter, and see if you have your files.

    Type <big>REN * *.doc</big> and press Enter (the big spaces are just for you to see what I wrote; only one is required after REN and after the first asterisk). This is the ONLY command you actually need, and all the rest is just "being careful"!

    Type DIR and press Enter, and see if everything has had its name changed
    Delete all the original files in the original directory and copy all the renamed ones to the original directory.
    When you're happy, delete the Cerfect directory and all the files

    If it works, be amazed how trivial some tasks are in a Command Prompt Window!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Rename all files in folder to add .doc extensi

    Samantha wrote
    <hr>I don't want to change the existing extension, just add .doc to the end<hr>
    Your commendably simple command line will try to change existing extensions to .doc. If there are two documents named Letter.eng and Letter.fra (which is normal usage for WordPerfect users), there would be a conflict.

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,892
    Thanks
    0
    Thanked 83 Times in 79 Posts

    Re: Rename all files in folder to add .doc extensi

    <code>Ren *.* *.*.doc</code> should work for that, I think. (assuming I put all the asterisks in the right places!)
    Regards,
    Rory
    Microsoft MVP - Excel.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Spokane, Washington, USA
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename all files in folder to add .doc extensi

    Thanks, John & Rory - I am duly amazed at how simple the process was. I'm also surprised at how easily old DOS commands came back to me.

    Unfortunately, it was only practical to use this method on the one folder that predates my tenure here. Up until 1996, the client files were all stuck in one huge annual folder. After I arrived, I oh-so-efficiently created a separate client folder under each annual folder. So from 1996 through sometime in 1998, when we migrated to Office, I would have to step through approximately 100 separate folders per year. Perhaps for the rest of the folders, it's time to check out kaplinb's suggested rename utility.

    Hans, I've filed away your macro for a day when I have time to play with it. I'm determined to learn VBA someday, but there never seems to be enough time. I learned to write batch files and Word Perfect macros simply by deconstructing what others had done and tweaking things to fit my needs. Somehow I don't think VBA is quite that simple.
    Samantha

    Everything in excess! To enjoy the flavor of life, take big bites. Moderation is for monks!
    Robert A. Heinlein - Time Enough for Love

  8. #8
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Rename all files in folder to add .doc extensi

    Yes, sorry, I missed the part about "existing extension". I was assuming that it was just a matter of changing FRED to FRED.DOC

    (Hence it being a good idea to copy stuff to a new directory first!).

    John

    PS It is possible to work down a directory structure using FOR /R <parameters> but the potential for making a rather large mess with this has always made me steer clear of it!
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

Posting Permissions

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