creativemind7 Posted November 12, 2011 Share Posted November 12, 2011 Dear Sir!I'm making a script which stores all paths of my files (including file names) to a Notepad file in seperate lines and also show file size.I coded the script, and it successfully stores my required information i.e (FilePath+FileName+File Size), but now i want to search in this text file (FileList.txt) for a specific string (i.e file size) and if the specific string is existed in my text file, then Autoit should give me the following results :-1) Copy only that lines to another Text File which have my required/specific string for which i am searching. (but remember only File Paths + File Names and not File size)Here is the example of Text File (FileList.txt).D:\My Documents\Coral Files\25 Hadiss.cdr 115254 bytesD:\My Documents\Coral Files\golden.cdr 36382 bytesD:\My Documents\Coral Files\Asif Card V9.cdr 13979070 bytesD:\My Documents\Coral Files\ASIF SHAHJEE CLERK.psd 11790593 bytesD:\My Documents\Coral Files\awan club.cdr 36382 bytesD:\My Documents\Coral Files\Bannu sugar mills card.cdr 15007036 bytesYou can see that every file has its path plus its size. i want to search for the string "36382". You can see that 36382 is in Line No. 2 and in Line No.5. i.e :D:\My Documents\Coral Files\golden.cdr 36382 bytesD:\My Documents\Coral Files\awan club.cdr 36382 bytesNow i want to copy these file's paths to another Text file (SearchList.txt) but only file path and its file name and not the file size. In other words i want to copy only red color text excluding blue color text to another text file (which could be named "SearchList.txt".that's all....I will be waiting for reply..........I may be also be informed by my following email address when some one expert gives reply.Thanks and forgive me for my English because English is not my mother language.Well Wisher: creativemind7@yahoo.com Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 12, 2011 Moderators Share Posted November 12, 2011 (edited) creativemind7,Welcome to the AutoIt forum. I would use _FileReadToArray to get the contents of your file into an array. You can then loop through the array and use StringInStr to see if the numerical value you require exists in a particular element. If it does, you can use the return value of StringInStr as the "count" parameter in StringMid to extract the path of the file. Finally you can use FileWriteLine to add this path to the new file you are creating. Pretty easy stuff - give it a go yourself. You know where we are if you need help. M23Edit: Amended function to use - thanks Zedna. Edited November 12, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Zedna Posted November 12, 2011 Share Posted November 12, 2011 I would use _FileListToArray to get the contents of your file into an array. Just small mistake:Melba surely meant _FileReadToArray() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 12, 2011 Moderators Share Posted November 12, 2011 Zedna, Thanks for picking that up. I have a dreadful cold at the moment and I am really not feeling myself. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
creativemind7 Posted November 13, 2011 Author Share Posted November 13, 2011 Melba and Zenda, Thanks for helping.... My code is working now in the light of your advice....... 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