Jump to content
UBot Underground

Finding A List Of Files Using Wildcards In The File Name


Recommended Posts

Ehum... This is kinda embarrassing... :)

I need to find lists of files that matches wildcards. In my case I always know the prefix of the file and the extension, but the rest might differ. For instance:

tesla--medium--01.jpg

tesla--medium--02.jpg

tesla--medium--07.jpg

tesla--medium--09.jpg

tesla--medium--00.jpg

tesla--medium--22.jpg

 

ford--medium--00.jpg

ford--big--05.jpg

ford--thumb--06.jpg

ford--big--09.jpg

ford--medium--10.jpg

ford--big--13.jpg

 

 

so in one case I would want to find all tesla--medium*.jpg files

 

in the other case I would want to find ford--big--*.jpg

 

Previously I have solved this with regular expressions which has worked ok although a massive overkill IMO, but now when I have 48000 files I get an out of memory exception. No wonder. :)

Can I do this in another way where I just name the filename with a wildcard and get the wanted files back as a list? Any plugin available?

 

 

Thanks!

Link to post
Share on other sites

Do you get the memory exception when you get the files or when you apply the regex? Without a plugin regex probably is the best way to go. If you have Elite Ubot plugin let me know and maybe I can add something in for this.

Link to post
Share on other sites

I don't have the Elite Ubot plugin.

 

I guess I will have to get a Windows IDE and dust off my old programming skills to create a plugin that does this for me. I will release it here if I ever get there. :) More ppl should have use for this.

 


(I did create a plugin a few years ago, just junk, but just to test it)

Link to post
Share on other sites

Do you get the memory exception when you get the files or when you apply the regex? Without a plugin regex probably is the best way to go. If you have Elite Ubot plugin let me know and maybe I can add something in for this.

 

Seems like a good plugin. No idea if it searches for files, but are you saying that you could add it with wildcard search too? I mean, a function that returns a list of files that matches a certain wildcard and/or Ubot variables.

 

Is that the idea?

Link to post
Share on other sites

I was asking because doing this is really simple and I knew I could just throw it in there if you had that plugin.

 

But if you want to make your own here is some code that shows you how to do it:

static void Main(string[] args)
        {
            string directory = ""; // path to the folder you want to search in
            string searchPattern = "tesla--*--*.jpg";

            string[] files = Directory.GetFiles(directory, searchPattern, SearchOption.AllDirectories);

            foreach (var file in files)
            {
                Console.WriteLine(file);
            }

            Console.ReadLine();
        }
Link to post
Share on other sites

Yep, the windows call is simple. Now I "just" need to get the UBotPlugin interfaces right. I have purchased your plugin instead and saved myself some work.

I hope that it still works with UBS 5.

 

(I can't use UBS 6 due to this:
http://network.ubotstudio.com/forum/index.php/topic/22502-is-60-good-now/?do=findComment&comment=137919

)

 

Pls let me know when it's done.

Link to post
Share on other sites

Yep, the windows call is simple. Now I "just" need to get the UBotPlugin interfaces right. I have purchased your plugin instead and saved myself some work.

 

I hope that it still works with UBS 5.

 

(I can't use UBS 6 due to this:

http://network.ubotstudio.com/forum/index.php/topic/22502-is-60-good-now/?do=findComment&comment=137919

)

 

Pls let me know when it's done.

 

It's finished, you can download the update by logging in here: https://elitebotters.com/my-account/

Link to post
Share on other sites

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...