Jump to content

Attempting to search folders for files.


Recommended Posts

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 by endothes
Link to comment
Share on other sites

  • Moderators

endothes,

Welcome to the AutoIt forum. :oops:

FileSelectFolder will let you choose a folder - look at _FileListToArray in the Help file to find out how to list the files within it. :bye:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by endothes
Link to comment
Share on other sites

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 by endothes
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...