endothes Posted March 15, 2012 Share Posted March 15, 2012 (edited) I've been attempting to create my first working script and it hasn't been going to well. My goal for this script is to log into a program, search a folder for .pdf file short names, from what the name says then upload the file into the program.The web-program is written in javascript if that relates to my issues. The main issue I am having is searching a folder of 500+ files and retrieving the short names of the file. Once the names have been gathered, upload them according to name. Example: File name: SMITH, THOMAS PROGRESS NOTE.PDF Smith will be entered into the search field. Thomas will be looked for in an adjacent field from Smith File will be uploaded as a Progress Note. Reading through many tutorials I've managed to produce a working script that will seamlessly log into the webpage and maneuver itself to the correct window to upload the files. I am not sure if the following command is correlated with searching and retrieving: $var10=FileSelectFolder("Choose a Folder.","") Thank you for taking the time to read through my post, any feedback will be greatly appreciated. Edited March 15, 2012 by endothes Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2012 Moderators Share Posted March 15, 2012 endothes,Welcome to the AutoIt forum. FileSelectFolder will let you choose a folder - look at _FileListToArray in the Help file to find out how to list the files within it. 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...
endothes Posted March 15, 2012 Author Share Posted March 15, 2012 Thank you Melba! I got a working list of every item in the folder. Time to continue with this script Link to comment Share on other sites More sharing options...
endothes Posted March 15, 2012 Author Share Posted March 15, 2012 (edited) Sorry for double-posting, I didn't want to create another thread so soon. Now that I am retrieving a list: [0]SMITH, JOHN, PROGRESS NOTE.pdf [1]BROWN, TIM, PROGRESS NOTE.pdf I am having trouble splitting the array. Is there possibly a way to split the list at the commas? This way I could send: [0]SMITH -- Into the clipboard [0]JOHN -- A value that will be searched [0]PROGRESS NOTE -- A value that determines placement Thank you for the help so far, I really do appreciate it! ;Generating a list of files MsgBox(0, "Select Folder", "Please Select a folder to search through") $var10=FileSelectFolder("Choose a Folder.","") ;Choose a folder to read from $FileList=_FileListToArray($var10) If @Error=1 Then MsgBox (0,"","No Folders Found.") Exit EndIf If @Error=4 Then MsgBox (0,"","No Files Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") Edited March 15, 2012 by endothes Link to comment Share on other sites More sharing options...
Country73 Posted March 15, 2012 Share Posted March 15, 2012 You may want to look at, in the Help File: "StringInStr" - checks if a string contains a given substring (verify the file name has what you want to split on) "StringSplit" - splits up a string into substrings depending on the given delimiters If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
endothes Posted March 15, 2012 Author Share Posted March 15, 2012 (edited) Thank you Country, I reviewed the help files again and they were very useful. Just can't seem to get it to work the way I want lol. MsgBox(0, "Select Folder", "Please Select a folder to search through") $var10=FileSelectFolder("Choose a Folder.","") ;Choose a folder to read from $FileList=_FileListToArray($var10) If @Error=1 Then MsgBox (0,"","No Folders Found.") Exit EndIf If @Error=4 Then MsgBox (0,"","No Files Found.") Exit EndIf _ArrayDisplay($Filelist,"$FileList"); Confirmation of items in folder $string=_ArrayToString($FileList, " ", 1, 1) $sub="," StringSplit($string, $sub) $a =FileGetShortName(String($string)) ClipPut($a) This is what I have right now. The array to string works perfectly. Splitting is the issue, it still creates one string for instance. I have in SMITH, THOMAS: I get pasted from the clipboard: SMITH THOMAS I am trying to get SMITH on one line and THOMAS on another line. Thank you so much for the help so far I've greatly improved my script! UPDATE: I cleaned up the script a little bit however i'm sure there are tons of shortcuts I could have used. MsgBox(0, "Select Folder", "Please Select a folder to search through") $var10=FileSelectFolder("Choose a Folder.","") ;Choose a folder to read from $FileList=_FileListToArray($var10) ;Create array from Folder If @Error=1 Then ;Display Error message MsgBox (0,"","No Folders Found.") Exit EndIf If @Error=4 Then ;Display Error message MsgBox (0,"","No Files Found.") Exit EndIf $sDelim="," ;Delim to distingusih lines $sString=_ArrayToString($FileList, $sDelim) ;Creating String from Array $String = $sString ;Creating command from string $Result = StringSplit($String, ",") ;Commanding result from split _ArrayDisplay($Result) ;Displaying result from split _ArrayToClip($Result, 2, 2) ;Copies array value 2 to clipboard Edited March 16, 2012 by endothes 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