Jump to content

FileExist in Subdirectoy


alexps2
 Share

Recommended Posts

Just want to know in how to use FileExist and wildcards to check if a file exist in a subdirectoy. The files that I have to check is in a folder created for each date with the format YYYYMMDD. An example for yesterday directoy would be "C:\USERDB\20101216\cng.cfg". What command would allow wildcards in AutoIt as fileexist doesnt supported.

Link to comment
Share on other sites

Hello alexps2,

First, Welcome to the AutoIt Forums :x

I an not sure what it is that your attempting to do with a limited description. Why do you want to check if a Wildcard exists?

However _FileListToArray() supports WildCards. You could load an entire directory into an array, and check for file *.cfg in a loop with a StringInStr($file,'.cfg'). Or if its the date you are wanting to WildCard you could create array of the dates you wish to choose, and build a loop using FileExist('C:\USERDB\' & $date[$i] & '\cng.cfg').

If neither of my descriptions are what you looking for, then please describe more in full:

1. What results you expect from your script/function

2. Show what code you have so far, or at least an example of it.

3. What problems your facing with your code.

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Hello alexps2,

First, Welcome to the AutoIt Forums :x

I an not sure what it is that your attempting to do with a limited description. Why do you want to check if a Wildcard exists?

However _FileListToArray() supports WildCards. You could load an entire directory into an array, and check for file *.cfg in a loop with a StringInStr($file,'.cfg'). Or if its the date you are wanting to WildCard you could create array of the dates you wish to choose, and build a loop using FileExist('C:\USERDB\' & $date[$i] & '\cng.cfg').

If neither of my descriptions are what you looking for, then please describe more in full:

1. What results you expect from your script/function

2. Show what code you have so far, or at least an example of it.

3. What problems your facing with your code.

Realm

Thanks!

I have for example this directories

C:\USERDB\20101216\cng.cfg

C:\USERDB\20101215\cng.cfg

C:\USERDB\20101214\cng.cfg

I want to check if cng.cfg File Exists in ("C:\USERDB")

Then RunWait()

Else

MsgBox()

Link to comment
Share on other sites

alexps2

So My second description should help you. What code do you have so far? What problems are you having with it?

I suggest using _FileListToArray('C:\USERDB') to enumerate the date directories into an array.

Then Create a Loop to go through all the Date Directories.

Inside your loop create a conditional check with FileExist() for 'cng.cfg'

If this condition exists than you can call RunWait() to run application.

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

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