escorpionmax Posted June 6, 2021 Share Posted June 6, 2021 Good morning. I am in need of some help, please. I am making a script that, during the execution, a folder has a new subfolder whose name is unknown. For example, let's say that DIR A has SUBDIR1, SUBDIR2, SUBDIR3. During the execution, a new subfolder X, is created. I need to get the name of that subfolder. I tried many ways, like creating and comparing arrays, but it seem i did something wrong because it didn't work. Can someone give me a little help, please? Thank you in advance. Best regards. Max Link to comment Share on other sites More sharing options...
Danp2 Posted June 6, 2021 Share Posted June 6, 2021 Suggest that you use the forum's search feature to look for the word "ReadDirectoryChangesW". Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Solution Subz Posted June 6, 2021 Solution Share Posted June 6, 2021 Here is a basic example using _FileListToArrayRec: #include <Array.au3> #include <File.au3> Global $g_sFolderRoot = @ScriptDir & "\Dir A" _ExampleFolders() ;~ Get list of folders before any changes are made Global $g_aFolderBefore = _FileListToArrayRec($g_sFolderRoot, "*", 2) ;~ Create Random Folder DirCreate($g_sFolderRoot & "\SubDir" & Round(Random(100, 500))) ;~ Get list of new folder(s) Global $g_aGetRandomFolder = _FileListToArrayRec($g_sFolderRoot, "*|" & _ArrayToString($g_aFolderBefore, ";", 1), 2) _ArrayDisplay($g_aGetRandomFolder) Func _ExampleFolders() If Not FileExists($g_sFolderRoot) Then DirCreate($g_sFolderRoot) For $i = 1 To 5 If Not FileExists($g_sFolderRoot & "\SubDir" & $i) Then DirCreate($g_sFolderRoot & "\SubDir" & $i) Next EndFunc Earthshine 1 Link to comment Share on other sites More sharing options...
escorpionmax Posted June 6, 2021 Author Share Posted June 6, 2021 Thank you very much guys. Just what i was looking for. Have a nice day Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now