Sign in to follow this  
Followers 0
HAMID

How I Detect Binary File Of Text File ?

4 posts in this topic

I Want To Detect Binary Files Of Text Files ;

How I Can This Job ?

Please Help Me .

Sorry For Bad English .

Share this post


Link to post
Share on other sites



I don't know what you mean with binary files of text files but here a WMI version to list

information about a file:

;coded by UEZ 2011
$file = FileOpenDialog("Select a file", "", "(*.*)")
If @error Then Exit
$objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2")
$colFiles = $objWMIService.ExecQuery("Select * from CIM_Datafile Where name = '" & StringReplace($file, "\", "\\") & "'")
If IsObj($colFiles) Then
    For $objFile In $colFiles
        ConsoleWrite( "Access mask: " & $objFile.AccessMask & @CRLF)
        ConsoleWrite( "Archive: " & $objFile.Archive & @CRLF)
        ConsoleWrite( "Compressed: " & $objFile.Compressed & @CRLF)
        ConsoleWrite( "Compression method: " & $objFile.CompressionMethod & @CRLF)
        ConsoleWrite( "Creation date: " & WMIDateStringToDate($objFile.CreationDate) & @CRLF)
        ConsoleWrite( "Computer system name: " & $objFile.CSName & @CRLF)
        ConsoleWrite( "Drive: " & $objFile.Drive & @CRLF)
        ConsoleWrite( "8.3 file name: " & $objFile.EightDotThreeFileName & @CRLF)
        ConsoleWrite( "Encrypted: " & $objFile.Encrypted & @CRLF)
        ConsoleWrite( "Encryption method: " & $objFile.EncryptionMethod & @CRLF)
        ConsoleWrite( "Extension: " & $objFile.Extension & @CRLF)
        ConsoleWrite( "File name: " & $objFile.FileName & @CRLF)
        ConsoleWrite( "File size: " & $objFile.FileSize & @CRLF)
        ConsoleWrite( "File type: " & $objFile.FileType & @CRLF)
        ConsoleWrite( "File system name: " & $objFile.FSName & @CRLF)
        ConsoleWrite( "Hidden: " & $objFile.Hidden & @CRLF)
        ConsoleWrite( "Last accessed: " & WMIDateStringToDate($objFile.LastAccessed) & @CRLF)
        ConsoleWrite( "Last modified: " & WMIDateStringToDate($objFile.LastModified) & @CRLF)
        ConsoleWrite( "Manufacturer: " & $objFile.Manufacturer & @CRLF)
        ConsoleWrite( "Name: " & $objFile.Name & @CRLF)
        ConsoleWrite( "Path: " & $objFile.Path & @CRLF)
        ConsoleWrite( "Readable: " & $objFile.Readable & @CRLF)
        ConsoleWrite( "System: " & $objFile.System & @CRLF)
        ConsoleWrite( "Version: " & $objFile.Version & @CRLF)
        ConsoleWrite( "Writeable: " & $objFile.Writeable & @CRLF)
    Next
Else
    ConsoleWrite("ERROR!" & @CRLF)
EndIf

Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 7, 2) & "." & StringMid($dtmDate, 5, 2) & "." & StringLeft($dtmDate, 4) & " " & _
                  StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2))
EndFunc   ;==>WMIDateStringToDate

There might be also a WinAPI version somewhere in the depth of this forum...

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

I Want To Detect Binary Files Of Text Files ;

How I Can This Job ?

Please Help Me .

Sorry For Bad English .

How i can detect binary file ?

For example docx,doc,swf,jpg are binary files

And txt,log,xml,ini,inf are text files

I want to read file content by FileRead() and detect that file is binary or text .

Share this post


Link to post
Share on other sites

Please realize that what you're asking for is ambiguous. Any "text file" _is_ a binary file but at the same time, any "binary file" can be interpreted as an ANSI text file (with possibly strange control characters). Sorting out which is which is at the very least difficult, in not plain impossible in the general case.

Relying on the final extension is a (naïve) way to work, but will not work in every situation.

In short, unless _you_ provide a clear and unambiguous definition of what _you_ consider "text" and, by reversal, "binary" I bet no definitive answer can be made, lest example code.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0