boniakowski Posted July 31, 2014 Share Posted July 31, 2014 Hello again. I´m working in a project of a Multiple hard drives duplicator, it´s for my job. I´m trying to find a way to put the searched strings in $Variables, but i don´t find the way in all the scripts what i´ve looking for. In my search i read all this topics: '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> and a lot more of this topics. but i doný find it. well this is my question i have some files .txt with the same structure with a little change some times for example: the file hdclone.1.txt have inside this lines: Target: ---------- Controller: IDE Device/Channel: 1 LUN: 0/0/2/1 Name: TOSHIBA MQ01ABF032 Serial number: 44TKCA87T Vendor: Firmware: AM001A Size: 320 GB Sector size: 512 B Number of sectors:625,142,448 Partition type: GPT Disk signature: {B0C19C59-E75C-4AA2-BF9D-410CC02826BD} but the file hdclone.2.txt append some lines like this: Target0: ---------- Controller: IDE Device/Channel: 1 LUN: 0/1/3/1 Name: TOSHIBA MQ01ABF032 Serial number: 44TKCA7RT Vendor: Firmware: AM001A Size: 320 GB Sector size: 512 B Number of sectors:625,142,448 Partition type: GPT Disk signature: {364C2481-C897-4AEA-A77C-FD97C8FE852E} Target1: ---------- Controller: IDE Device/Channel: 3 LUN: 0/0/2/1 Name: TOSHIBA MQ01ABF032 Serial number: 44TKCA87T Vendor: Firmware: AM001A Size: 320 GB Sector size: 512 B Number of sectors:625,142,448 Partition type: GPT Disk signature: {B036BCD1-5CB1-437A-B782-D678D89259B6} Now you´ll see like the line Target: was converted to Target0: and down repeat the same structure but append different Targets with always the same tags Target1: ---------- well i´m looking for this: i need to put in a variable the result of the serial number of Target: and every Target inside the file if exists and the port in this case named: Example: LUN: 0/0/2/1 Example: Target0: Serial number: 44TKCA7RT Port: LUN: 0/1/3/1 Target1: Serial number: 44TKCA87T Port: LUN: 0/0/2/1 I only can do this for now, i have a for cicle to search every line inside the files but i don´t understand how to do the rest. $file = FileOpen("f:\hdclone.1.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached $aArray=FileReadToArray($file) For $i = 0 To UBound($aArray) - 1 ; Loop through the array. MsgBox(0, "", $aArray[$i]) ; Display the contents of the array. Next MsgBox(0,"",$aArray) FileClose($file) can anyone send me a life guard with this? Thanks. Christian hdclone.1.txthdclone.2.txthdclone.3.txt Link to comment Share on other sites More sharing options...
careca Posted July 31, 2014 Share Posted July 31, 2014 (edited) #include <Array.au3> $result = FileOpen(@ScriptDir &'\Result.txt', 2) $file = FileOpen(@ScriptDir &'\hdclone.1.txt') $aArray=FileReadToArray($file) _ArrayDisplay($aArray) Local $Target, $Lun, $Serial For $i = 0 To UBound($aArray)-1 ConsoleWrite($aArray[$i] &@CRLF) $Target= StringInStr($aArray[$i],'target:',2) If $Target <> 0 Then ConsoleWrite( $aArray[$i] &@CRLF) FileWriteLine($result, $aArray[$i]) EndIf $Lun= StringInStr($aArray[$i],'LUN:',2) If $Lun <> 0 Then ConsoleWrite( $aArray[$i] &@CRLF) FileWriteLine($result, $aArray[$i]) EndIf $Serial= StringInStr($aArray[$i],'Serial number:',2) If $Serial <> 0 Then ConsoleWrite( $aArray[$i] &@CRLF) FileWriteLine($result, $aArray[$i]) EndIf Next FileClose($file) FileClose($result) $result = FileOpen(@ScriptDir &'\Result.txt') MsgBox(64, '', FileRead($result)) FileClose($result) For that file it also find the "Source" serial, and Lun. Edited July 31, 2014 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now