Jump to content

Looking for changes in a folder

Go to solution Solved by Subz,

Recommended Posts

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.


Link to post
Share on other sites
  • Solution

Here is a basic example using _FileListToArrayRec:

#include <Array.au3>
#include <File.au3>

Global $g_sFolderRoot = @ScriptDir & "\Dir A"
;~ 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)

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)


Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...