Jump to content
UBot Underground

[Solved]checking for file existing before opening


Recommended Posts

I have a bot that loops through some steps including opening a local file and doing stuff with the data.

The problem that comes up is the bot will stop with an error if the file it tries to open doesnt exist.

 

So, is there an easy way to check to see if the file exists before opening it?

 

 

I have ideas for a complicated way using the get files, but I figured there might/should be an easier way.

 

And bring up the get files... I tried using that with the path off and it still brings in the path.

 

 

 

Thanks

 

-Charles

Link to post
Share on other sites

You can also write the get files results to a new browser and use if--->exists

 

 

John

 

Thanks John, is it possible to get some code for this? I can't even find the write to browser function that used to be in 3.5.

Link to post
Share on other sites

this is how i'm doing it:

 

define $file_exists(#if_exists_filename) {
   clear list(%fileslist)
   add item to list(%fileslist, $get files($special folder("Application"), "No"), "Delete", "Local")
   if($contains(%fileslist, #if_exists_filename)) {
       then {
           set(#file_exist_found, $true, "Global")
       }
       else {
           set(#file_exist_found, $false, "Global")
       }
   }
   return(#file_exist_found)
}

  • Like 2
Link to post
Share on other sites

this is how i'm doing it:

 

define $file_exists(#if_exists_filename) {
   clear list(%fileslist)
   add item to list(%fileslist, $get files($special folder("Application"), "No"), "Delete", "Local")
   if($contains(%fileslist, #if_exists_filename)) {
       then {
           set(#file_exist_found, $true, "Global")
       }
       else {
           set(#file_exist_found, $false, "Global")
       }
   }
   return(#file_exist_found)
}

 

Thanks mate, that's a great solution!

Link to post
Share on other sites

this is how i'm doing it:

 

define $file_exists(#if_exists_filename) {
   clear list(%fileslist)
   add item to list(%fileslist, $get files($special folder("Application"), "No"), "Delete", "Local")
   if($contains(%fileslist, #if_exists_filename)) {
       then {
           set(#file_exist_found, $true, "Global")
       }
       else {
           set(#file_exist_found, $false, "Global")
       }
   }
   return(#file_exist_found)
}

 

 

This worked great for me.

Thanks

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