Jump to content

Trying to Find a Particular Subdirectory When Know Part of the Parent Path


Go to solution Solved by pixelsearch,

Recommended Posts

Posted

Greetings! I seem to be missing/misunderstanding something. I am trying to find the full path to "Dir7", below, when I know most of the path, except for one grandparent folder whose name can change over time. I thought the below would work, but it does not seem to for some reason (ie, it returns -1, indicating nothing was found).

$hSearch = FileFindFirstFile("C:\Dir1\Dir2\Dir3\Dir4\Dir5\*\Dir6\Dir7")

Once I successfully find the current/actual path to "Dir7" I then intend to do some things with a few files (whose names I know) within it.

Is this the wrong function to be using, and/or am I misunderstanding how to properly use it in this instance?

Thanks much for any assistance!
:)

  • Solution
Posted (edited)

Hello
Maybe there's an easier solution, but this is what I have in mind actually :

1) Retrieve the folder names existing under the path C:\Dir1\Dir2\Dir3\Dir4\Dir5\
This could be done with the function _FileListToArray when using its flag $FLTA_FOLDERS which returns folders only

2) Loop through each folder name returned to check if your full path exists, for example :

C:\Dir1\Dir2\Dir3\Dir4\Dir5\folder1_returned\Dir6\Dir7\ ; path doesn't exist
C:\Dir1\Dir2\Dir3\Dir4\Dir5\folder2_returned\Dir6\Dir7\ ; path doesn't exist
C:\Dir1\Dir2\Dir3\Dir4\Dir5\folder3_returned\Dir6\Dir7\ ; path exists, bingo !

The function FileExists ("checks if a file or directory exists") could be used for part 2)
Good luck

Edited by pixelsearch
typo

"I think you are searching a bug where there is no bug... don't listen to bad advice."

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
×
×
  • Create New...