Jump to content
UBot Underground

Opening a folder and reading all files within that folder


Recommended Posts

Would anyone know how to get a script to recognize all files within a folder and open each file within that folder until they are done?

 

For example: I want to be able to select a folder with the ui open file button and have the bot go through, open and read all text files within that folder - one at a time until they are all read. I can't seem to find a way to do this.

 

Can anyone steer me in the right direction on how to do this?

 

Cheers.

Link to post
Share on other sites

Just to clarify, I want to get a script to read the content within a text file or several text files that are contained within a folder. I know how to get it to read the names of each file within a folder, but not the content within each of those files.

 

If anyone knows how to do this, can they let me know?

 

Cheers.

Link to post
Share on other sites

Hi guys, I tried those things and I couldn't quite get it to do what I wanted. I want to be able to use the ui open file function to select a folder, not a file and have the script read content on each text file that is contained within that folder.

 

For example: I select a folder called - "My Folder" and within that folder are 10 text files with content on them, I want to be able to select that folder with the ui - open file function and see that "My Folder" has been selected in the ui and from there, the script selects and runs through the content on each file within that folder - one by one until they are all done.

 

Any help with ideas about this would be appreciated.

 

Cheers.

Link to post
Share on other sites

You need a plugin from Aymen to do that "Dialog Functions > folder browser dialog

 

You then need this code

ui button("Select 
Folder") {    set(#mydocs, $plugin function("File 
Management.dll", "$folder 
browser dialog"), "Global")}
  • Like 1
Link to post
Share on other sites

 

You need a plugin from Aymen to do that "Dialog Functions > folder browser dialog

 

You then need this code

ui button("Select 
Folder") {    set(#mydocs, $plugin function("File 
Management.dll", "$folder 
browser dialog"), "Global")}

 

Thanks zap, that's exactly what I was looking for, cheers.

 

I installed the plugin and the script and it now opens folders but I am still trying to work out how to get a text box or a form on a page to recognize the text that is on the files within the folder, I just get the name of the path of the folder and not what's in the files. It's probably something simple but for now I'm trying to work it out.

Link to post
Share on other sites

I've been trying the read file function, but I can only get it to read one file and not all the files within a folder. It would be good if there was a read folder function.

Link to post
Share on other sites

ui button("Select Folder") {
    set(#mydocs, $plugin function("File Management.dll""$folder browser dialog"), "Global")
    set(#mydocs$find regular expression($get files(#mydocs"Yes"), ".*\\.\\btxt\\b"), "Global")
    clear list(%mydocs)
    add list to list(%mydocs$list from text($trim(#mydocs), $new line), "Delete""Global")
    set list position(%mydocs, 0)
    loop($list total(%mydocs)) {
        load html($read file($next list item(%mydocs)))
        wait(4)
    }
}

 

 

 

 

The regex makes it add only .txt files

  • Like 1
Link to post
Share on other sites

Thanks again zap, that was exactly what I was looking for.

 

The script seems to run by itself though as soon as I select the folder and the - "run", "pause" and "stop" functions seem to not work at all. I can't understand why it does that.

 

Is there any info anywhere that explains what this means? -   ".*\\.\\btxt\\b" 

 

Also, I am trying to get the script to recognize spintax and to not remove the blank spaces. It's for articles in notepad files. I tried all the text functions, but they all seem to alter the text in some way that I'm not looking for and when I tried the "nothing" function to replace the "new line" function, the script had an error and wouldn't run.

 

I put #spin where #trim used to be, but that made no difference.

 

Any ideas on how to get it to spin the text and leave the blank spaces as is?

Edited by Glassy
Link to post
Share on other sites

Is there any info anywhere that explains what this means? - ".*\\.\\btxt\\b"

google regular expression, cheat sheet

 

The script seems to run by itself though as soon as I select the folder and the - "run",

Move the loop out of the run button

 

 

Not sure this is what you wout to do as it will only spin each file once

ui button("Select Folder") {

    set(#mydocs, $plugin function("File Management.dll""$folder browser dialog"), "Global")

    set(#mydocs$find regular expression($get files(#mydocs"Yes"), ".*\\.\\btxt\\b"), "Global")

    clear list(%mydocs)

    add list to list(%mydocs$list from text($trim(#mydocs), $new line), "Delete""Global")

    set list position(%mydocs, 0)

}

loop($list total(%mydocs)) {

    load html($spin($read file($next list item(%mydocs))))

    wait(4)

}

 

 

 

 

Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...