I have a lot of dgn files and don’t know which are V7 and which are V8. Is there a way to quickly and easily tell them apart? I would hate to have to go through and open them up individually.
Do you know how to use PowerShell? I wrote a PowerShell function that will give a file's magic number (https://en.wikipedia.org/wiki/Magic_number_(programming)#In_files) and if it recognizes the magic number the file type. It can recognize V7 and V8 files.
The function is on GitHub here: Get-MagicNumber on GitHub
Put that function in a file, then open PowerShell and do:
. filename.ps1
where the first character is period, then space, then the name of the ps1 file you put the function in.
Once you've done that you can cd to your folder of files and do the following:
dir *.dgn -recurse -file | Get-MagicNumber | Format-Table File,FileType Where: -recurse means to get all *.dgn files in the current folder and sub-folders -file means only return info about files
You can also use the Export-Csv command instead of Format-Table to send the info to a CSV file instead of the screen.
I cant use PowerShell for "reasons". I'll have to pursue other scripting means. The magic number information is helpful, thank you.
I ran a script to pull the magic number of my DGNs and complied a list of valid ones. Thought it may help who ever comes across this.
Magic number: 4143313030390000 - R11/12 DWGMagic number: 4143313031340000 - R14 DWGMagic number: 4143313031350000 - R2000 DWGMagic number: 4143313031380000 - R2004 DWGMagic number: 4143313032340000 - R2010 DWGMagic number: 4143313032370000 - R2013 DWGMagic number: 4143313033320000 - R2018 DWGMagic number: 0809fe0200000000 - V7 DGNMagic number: 0809fe0200000108 - V7 DGNMagic number: 0809fe0200000188 - V7 DGNMagic number: 0809fe0200000881 - V7 DGNMagic number: 0809fe0200800108 - V7 DGNMagic number: 0809fe0201080000 - V7 DGNMagic number: 0809fe0201880080 - V7 DGNMagic number: 0809fe0208010000 - V7 DGNMagic number: 0809fe0263726f73 - V7 DGNMagic number: 0809fe0270656e75 - V7 DGNMagic number: 0809fe0274657374 - V7 DGNMagic number: 0809fe02776f726b - V7 DGNMagic number: c809fe0200000000 - V7 DGNMagic number: c809fe0200000188 - V7 DGNMagic number: c809fe0201080000 - V7 DGNMagic number: c809fe0201880080 - V7 DGNMagic number: c809fe0208010000 - V7 DGNMagic number: d0cf11e0a1b11ae1 - V8 DGN
Magic numbers aren't a fixed length, each application sets its own length, the magic number for a V7 file is c809fe02, the other numbers you're showing are part of the file data and can be ignored.
on DWG the first 4 bytes are always the ascii codes for AC10 (41433130) then the next 2 bytes are the version. Anything after the first 6 bytes is either padding or file data.
The v8 file format is special, it's actually a file format from Microsoft, not Bentley. It's called the Microsoft Compound File Binary File Format and may be used by more than MicroStation on your computer. So you may find a file with the same magic number but isn't actually a dgn file.
Also, I recently found this set of file formats at the US Library of Congress website. It's not comprehensive but has a lot of file formats. The ones I've check so far all have magic numbers
www.loc.gov/.../descriptions.shtml
John Doe said:I'll have to pursue other scripting means
it would be helpful if you published here what the alternative scripting was, I never heard of magic number in DOS and I'm not much use in powershell .. in your list of magic number outputs below
John Doe said:Magic number: 0809fe0200000000 - V7 DGNMagic number: 0809fe0200000108 - V7 DGN
the magic numbers vary between same format is this normal? Does your script add the type at the end, does it indicate the file names too like the poweshell script does
Lorys
Started msnt work 1990 - Retired Nov 2022 ( oh boy am I old )
But was long time user V8iss10 (8.11.09.919) dabbler CE update 16 (10.16.00.80)
MicroStation user since 1990 Melbourne Australia.click link to PM me
I used a python script generated by chatgpt. It reads the first 8 bytes of all DGNs and outputs each unique "magic number" found among other things. I don't know if the variation is normal but that's what the script found.