Jump to content

asgarcymed

Active Members
  • Posts

    96
  • Joined

  • Last visited

About asgarcymed

  • Birthday 09/06/1980

Profile Information

  • Location
    Portugal
  • WWW
    http://asgarcymed.blogspot.com/
  • Interests
    Medicine, Computers & Internet, Psychology, Philosophy, Sociology, Anthropology, Languages (English, German, Spanish, Italian, French)

asgarcymed's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Sometimes, files downloaded in eMule (ed2k) are fakes - porno movies renamed to a wrong extension (for example - zip). When I try to open them with the supposed appropriate program (for example, zip is expected to open with WinZip), of course, I get an error message, since the file is a video file awry renamed to other extension. This is the reason why I cannot give up from getting a way (script) to automatically scan all files inside my eMule's Download Folder; detect and isolate faked files... On the other hand, I know some curious facts: *) "Universal Extractor" [http://www.legroom.net/software/uniextract] is a superb application programmed in AutoIt Language; *) "Universal Extractor" sometimes uses "TrID" [http://mark0.net/soft-trid-e.html] to help in detection of "file type/identification"... Thus, I had an idea: see Universal Extractor's source-code (.au3) and try to imitate the methodology around using TrID to get file type/identification... TrID is a command-line tool, which have the syntax: trid.exe "file.ext" [+/- optional parameters] The people that coded Universal Extractor did => scan each file with trid.exe => write a log/text file containing TrID scan's results => compare strings between what is expected and what TrID truly says... I tried to imitate this, but my script does not work... Here it is: #include <Array.au3> #include <File.au3> $path = "C:\eMule\Incoming" $fso = ObjCreate("Scripting.FileSystemObject") $obj_dict = ObjCreate("Scripting.Dictionary") $obj_dict.CompareMode = 1 ; "Text Mode" $array_files = _FileListToArray($path, "*.*") For $n = 1 To $array_files[0] $attribs = FileGetAttrib($path & "\" & $array_files[$n]) If Not StringInStr($attribs, "D") Then RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\" & $array_files[$n] & """" & " > " & @TempDir & "\" & """" & $array_files[$n] & """" & ".TrID.log", "", @SW_HIDE) $open_log_file = FileOpen(@TempDir & "\" & $array_files[$n] & ".TrID.log", 0) $read_log_file = FileRead($open_log_file) ConsoleWrite($read_log_file & Chr(13)) $fso_get_file = $fso.GetFile ($path & "\" & $array_files[$n]) $extension = $fso.GetExtensionName ($fso_get_file) ConsoleWrite($extension & Chr(13)) Switch $extension Case "chm" If Not StringInStr($read_log_file, "Windows HELP File") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "djvu" Or "djv" If Not StringInStr($read_log_file, "DjVu file") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "doc" If Not StringInStr($read_log_file, "Microsoft Word document") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "html" Or "htm" If Not StringInStr($read_log_file, "HyperText Markup Language") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "mht" If Not StringInStr($read_log_file, "Microsoft Internet Explorer Web Archive") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "mpg" If Not StringInStr($read_log_file, "MPEG Video") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "pdb" If Not StringInStr($read_log_file, "Palm iSilo") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "pdf" If Not StringInStr($read_log_file, "Adobe Portable Document Format") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "ppt" Or "pps" If Not StringInStr($read_log_file, "Microsoft PowerPoint document") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "rar" If Not StringInStr($read_log_file, "RAR Archive") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case "zip" If Not StringInStr($read_log_file, "RAR Archive") Then FileMove($path & "\" & $array_files[$n], $path & "\TrID\", 8) FileCopy(@TempDir & "\" & $array_files[$n] & ".TrID.log", $path & "\TrID\") RunWait(@ComSpec & " /c " & "trid.exe " & """" & $path & "\TrID\" & $array_files[$n] & """" & "-ae", "", @SW_HIDE) EndIf Case Else If Not $obj_dict.Exists ($extension) Then FileWrite(@DesktopDir & "TrID - MISSING EXTENSIONS.log", $extension) $obj_dict.Add ($extension) EndIf EndSwitch $close_log_file = FileClose($open_log_file) $delete_log_file = FileDelete(@TempDir & "\" & $array_files[$n] & ".TrID.log") EndIf Next I am in despair; my brain is boiling; can you please help me? Thanks in advance. Regards.
  2. PsaltyDS - thank you very much!!!!!!!!!!!!! You solved my problem and I learned with it!!!
  3. Obviously, this problem/script makes no sense when considered alone, "per se". I felt this problem when I was trying to make a much more complex script, like this: A text file contains one md5 hash/checksum per line (corresponding to one file; this text file was previously made, and in the present moment I do not have direct access to such files, only to their md5 hash/checksum, stored in the text file) => the script reads such text file and each line (md5 hash/checksum) is added, as key, to the dictionary object => => Next step: Look at a specified directory (now I have direct access to this directory and its files) => for each file, one-by-one, get md5 hash/checksum (using an ActiveX=COM object) => If a repeated md5 is found (means duplicate file) then delete file [the dictionary's "Exists" method checks and does not allow 2 keys to be equal. Thus, if a duplicate file exists, the keys (md5) would be equal...) Here it is my full script: $path = "C:\test" $txt_file = @DesktopDir & "\MD5.txt" $obj_md5 = ObjCreate("XStandard.MD5") ; ActiveX MD5 Hash/CheckSum $open_file = FileOpen($txt_file, 0) $obj_dict = ObjCreate("Scripting.Dictionary") If IsObj($obj_dict) Then $obj_dict.CompareMode = 1; "Text Mode" Else Exit 1 EndIf $x = 0 While 1 If @error = -1 Then ExitLoop $line = FileReadLine($open_file) $dict_key = $line $x = $x + 1 $obj_dict.Add ($dict_key, $x) WEnd $search = FileFindFirstFile($path & "\*.*") $y = 0 While $search = 1 If @error Then ExitLoop $file = FileFindNextFile($search) $md5_hash = $obj_md5.GetCheckSumFromFile ($file) $dict_key2 = $md5_hash $y = $y + 1 If $obj_dict.Exists ($dict_key2) Then FileRecycle($file) Else $obj_dict.Add ($dict_key2, $y) FileWrite($txt_file, $dict_key2 & Chr(13)) ; Update MD5.txt File => New File (not duplicated) EndIf WEnd However this script does not work and alone, with no help, I cannot make it work... Can you help me? PS - WeaponX - I tried: Read Line to Array => Add to Dictionary [the problem is that such text file contains 10000 lines, what exceeds the array size in AutoIt... Unlike this, Object Dictionary has no limits of elements number...] Thanks in advance. Regards.
  4. I have a text file which contains many lines (no duplicate lines); and I am trying to add each line to the Dictionary Object. I cannot understand what is going wrong, but when EOF (End-of-File) is reached, I get an error message: "The requested action with this object has failed" My script is: $txt_file = @DesktopDir & "\Text-Lines.txt" $open_file = FileOpen($txt_file, 0) $obj_dict = ObjCreate("Scripting.Dictionary") $obj_dict.CompareMode = 1 ; "Text Mode" $x = 0 While 1 If @error = -1 Then ExitLoop $line = FileReadLine($open_file) $dict_key = $line $x = $x + 1 If IsObj($obj_dict) Then $obj_dict.Add ($dict_key, $x) If @error Then ExitLoop EndIf Else ExitLoop EndIf TrayTip("Line " & $x, $dict_key, 1) WEnd Can you please help me to correct/debug this script? Thanks in advance. Best regards.
  5. Bowmore - thank you for replying!... To solve this once and for all, could you please post the complete script (with the correct sequence of different RegEx's)? Please note that today is the first day in my life in that I deal with RegEx's... If you help me, you can be sure I will study this so important subject that I was missing out; from your precious help... Thank you! Regards.
  6. PS - If you have problems with the file attached; please see: http://www.xys.org/xys/netters/others/net/wiki2.txt Thanks. Regards.
  7. I am now using "RegExBuddy", a superb Win32 app to work and learn about Regular Expressions... Using Google, I could get a txt file (inside zip attached) which has many, many Chinese characters; and few English characters... I opened it with RegExBuddy, and I tested both RegEx's: [\x10-\x1F\x21-\x2F\x3A-\x40\x5B-\x60\x80-\xFF] and [^\u0000-\u024F]+ But the results of test/debug were very confusing... Even more - I got the Windows XP MUI (MultiLingual User Interface) and I installed all languages I already announced (Chinese/Japanese/Korean/Arabic/Hebraic/Russian)... My confusion is now even bigger - some apps can correctly load the Chinese characters (for example), but the majority of apps continue not to deal with such characters (they show "squares" or "???????????" or distorted characters like when we try to read a binary file with a text editor... A big confusion is installed in my brain... Must I have MUI installed ?... What is the best RegEx to kill such characters from files' names? If I have MUI installed, do I need such regex/script?? What should I do to solve this question once and for all? Is there any Chinese/Japanese/Korean/Arabic/Hebraic/Russia person here? If yes, how do you manage the characters' conflicts between your Native Language and English? Help is very appreciated! Thanks in advance. Regards. CHINES.zip
  8. I need to allow: All English/German and Latin (Portuguese/Spanish/French/Italian) letters, lower and upper case [A..Z; À; Ã; É; Ê; Í; Ì; Ó; Ò; Õ; Ñ; Ç] AND !; ""; #; $; %; & @; £; §; {; }; '; «; »; [American and European Keyboard] I very urgently need to kill ALL Chinese, Japanese, Korean, Arabic, Hebraic, Russian characters (all letters are "crazy")... Could this be?: StringRegExpReplace ("", "[^\u0000-\u024F]+", "_") trying: \p{InBasic_Latin}: U+0000..U+007F \p{InLatin-1_Supplement}: U+0080..U+00FF \p{InLatin_Extended-A}: U+0100..U+017F \p{InLatin_Extended-B}: U+0180..U+024F Is there any UniCode and RegEx expert? Thanks. Regards.
  9. A "MUST"!... Look at: http://www.isthisthingon.org/unicode/allchars1.php All characters are there! My problem is that I do not know how to make the RegExp... Please help! Thank you! Regards.
  10. Thank to all of you for replying! Saunders - you are correct - Chinese/Japanese/Korean/Arabic/Hebraic/Russian characters MUST be replaced by underscores (because of the reason you very well posted)... I still need help about such StringRegExpReplace... Maybe someone who is from one of such countries, and then, must deal with both languages... Thanks. Regards.
  11. PS - if you want to see such characters, you can see Wikipedia in all of these (esoteric) languages... Regards.
  12. In Windows XP English, all unicode/illegal character strings appear as a "square" or a "?" Only if someone has the MUI (MultiLingual User Interface) will see the correct Chinese/Japanese/Korean/Arabic/Hebraic/Russian characters ?????? ????? ?????????? => this was my attempt to make a copy-paste... This forum also does not support Chinese/Japanese/Korean/Arabic/Hebraic/Russian characters...
  13. Many files downloaded by eMule (ed2k/Kad) contain, in its name, UniCode characters (such as Chinese, Japanese, Korean, Arabic, Hebraic, Russian) which are seen as "Illegal Characters" by English version of Windows XP's explorer.exe... This causes serious troubles when managing such files... Thus, I would like to get a script to automatically delete such characters from files' name, in order to avoid problems when trying to access them... PS - even when we download an eBook totally written in English, stupidly the files' names contain such unicode/illegal characters... Thanks. Regards.
  14. First, I want to thank to all of you for your help! My problem was perfectly solved using the last script that WeaponX posted; and I learned a lot with all your posts! Recursion in AutoIt continues to be a very hard task for me; but I feel very enthusiastic to learn it deeply, with your help! I most use AutoIt for Files and Folders managing, thus recursion is very important for me Thank you very much! Best regards.
  15. goldenix - thank you for answering and posting a so very good URL ("Daily Cup of Tech") Recursion in AutoIt always have been a nightmare for me... Any good tutorial about recursion is always welcome to me Nevertheless, this concrete problem remains unsolved... This script you posted has the same problem as DBak's one <=> it recursively lists list all *.par2 files; but NOT ONLY inside directories which ONLY have *.par2 files... Example: Main\Dir1\01.rar Main\Dir1\02.par2 Main\Dir2\03.par2 Dir1 does not matter because have other extensions (rar); NOT ONLY par2 Dir2 is what I want => no other extension exist; ONLY par2 Does anyone have a brilliant idea how to do this? I really need it, but my knowledge is not enough ;( Please help... Thanks. Regards
×
×
  • Create New...