Identify an AutoCAD file without the dwg extension

Discussion in 'AutoCAD' started by ruifrazao, Jan 5, 2004.

  1. ruifrazao

    ruifrazao Guest

    Hi,

    How can I know if a file is an AutoCAD file, when the file does not have the dwg extension?

    I have a folder with a lot of files and all them without extension (dwg, doc, txt, …). How can I know witch these files are AutoCAD files?

    Thanks,

    Rui
     
    ruifrazao, Jan 5, 2004
    #1
  2. Do you have show extensions turned on under folder options?
    David

    Hi,

    How can I know if a file is an AutoCAD file, when the file does not have the
    dwg extension?

    I have a folder with a lot of files and all them without extension (dwg,
    doc, txt, .). How can I know witch these files are AutoCAD files?

    Thanks,

    Rui
     
    David Claflin, Jan 5, 2004
    #2
  3. ruifrazao

    ruifrazao Guest

    This is not my problem. Is not just a windows configuration.

    In my case, all files do not have the extension.

    I have a huge quantity of files in one folder. These files have the name encrypted because they come from a document management software.

    And I need to separate all AutoCAD files.

    Thanks,

    Rui
     
    ruifrazao, Jan 5, 2004
    #3
  4. Read the first 6 bytes of the file .
    If it's an AutoCAD file it should have the dwg format version, something
    like AC1015 (the first 2 chars 'AC' will always be there, the numbers
    depend on the AutoCAD version)
    Haven't tried it for 2004 format though.

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica

    encrypted because they come from a document management software.
     
    Jorge Jimenez, Jan 5, 2004
    #4
  5. ruifrazao

    ruifrazao Guest

    Thanks.
    Rui
     
    ruifrazao, Jan 5, 2004
    #5
  6. ruifrazao

    Matt W Guest

    Here's a little suttin' I whipped together... You'll have to add a reference to the MS Scripting Runtime. This will check the version of a drawing (without the extension) called drawing1 and then rename it to drawing1.DWG. You'll have to add a little more to loop through all of the drawings in the directory, but this should get you started.

    Public Sub Test()
    MsgBox DrawingVersion("e:\drawing1")
    End Sub

    ' I believe this code came from Randall Rath
    Public Function DrawingVersion(fName As String)
    Dim fso As New FileSystemObject
    Dim DwgHeader As String * 6
    Dim DwgFile As Long
    Dim version As String

    DwgFile = FreeFile(0)

    Open fName For Binary Access Read As #DwgFile
    Get #DwgFile, , DwgHeader
    Close #DwgFile
    DrawingVersion = DwgHeader

    Select Case DwgHeader
    Case "AC1018": 'Autocad 2004
    DrawingVersion = "AutoCAD 2004"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1015": 'Autocad 2000
    DrawingVersion = "AutoCAD 2000+"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1014":
    DrawingVersion = "AutoCAD 14"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1013":
    DrawingVersion = "AutoCAD 14"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1012":
    DrawingVersion = "AutoCAD 13"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1011":
    DrawingVersion = "AutoCAD 13"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1010":
    DrawingVersion = "AutoCAD 13"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1009":
    DrawingVersion = "AutoCAD 11/12"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1006":
    DrawingVersion = "AutoCAD 10"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1004":
    DrawingVersion = "AutoCAD 9"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1003":
    DrawingVersion = "AutoCAD 2.6"
    fso.MoveFile fName, fName & ".dwg"
    Case "AC1002":
    DrawingVersion = "AutoCAD 2.5"
    fso.MoveFile fName, fName & ".dwg"
    Case Else: 'Unknown Header
    DrawingVersion = "Unrecognized Version"
    End Select
    End Function

    HTH
    ~ Matt W
     
    Matt W, Jan 5, 2004
    #6
  7. ruifrazao

    ruifrazao Guest

    Thanks.

    And for Word and Excel files?

    Do you have idea if exists something similar?
    If is possible identify them, without the extension?

    Thanks again
    Rui
     
    ruifrazao, Jan 15, 2004
    #7
  8. ruifrazao

    ruifrazao Guest

    Thanks.

    And for Word and Excel files?

    Do you have idea if exists something similar?
    If is possible identify them, without the extension?

    Thanks again
    Rui
     
    ruifrazao, Jan 15, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.