Jump to content

Is it possible to list all files in a folder as well as subfolders?


Recommended Posts

Pretty much what the title states.

Suppose you have a folder containing 3 subfolders and 4 files.

The first subfolder contains 5 files, the second one 14 and the third one just 1.

How can I collect all those files/file paths (4 + 5 + 14 + 1 = 24) in a single array?

Link to comment

Yes, u right click ur folder and u selecx tr properties. -drunken response for fun, for not including details, like in what moding tool and such.

Also let it be known, that in Weidu's tp2 commands, you can copy a folder and it's content will dump it to the override folder and it will be there as is after. But it doesn't like subfolders, so don't use them, or use multiple copy commands for different purposes.

Edited by Jarno Mikkola
Link to comment
Posted (edited)
50 minutes ago, Jarno Mikkola said:

like in what moding tool and such.

I'm talking about WeiDU...

50 minutes ago, Jarno Mikkola said:

Also let it be known, that in Weidu's tp2 commands, you can copy a folder and it's content will dump it to the override folder and it will be there as is after.

There's the inline mode for that...

Edited by Luke
Link to comment

It's certainly possible with the WeiDU commands GET_DIRECTORY_ARRAY and GET_FILE_ARRAY. Arrays can be expanded dynamically simply by assigning new values to the array.

Example:

// Retrieve list of subfolders
GET_DIRECTORY_ARRAY ~paths~ ~%MOD_FOLDER%/mypath~ ~.+~

// Collect file entries
OUTER_SET index = 0
ACTION_PHP_EACH paths AS _ => current_path BEGIN
  // Skip special folder names "." and ".."
  ACTION_IF (~%current_path%~ STRING_MATCHES_REGEXP ~.*/\.\.?~ != 0) BEGIN
    GET_FILE_ARRAY ~files~ ~%current_path%~ ~.+~
    ACTION_PHP_EACH files AS _ => file_name BEGIN
      OUTER_TEXT_SPRINT $my_array(~%index%~) ~%file_name%~
      OUTER_SET index += 1
    END
    ACTION_CLEAR_ARRAY ~files~  // prevents false positives when array is reused in the next pass
  END
END

// Output:
OUTER_FOR (i = 0; i < index; ++i) BEGIN
  OUTER_TEXT_SPRINT file $my_array(~%i%~)
  PRINT ~File %i%: %file%~
END

 

Link to comment
1 hour ago, Luke said:

Pretty much what the title states.

Suppose you have a folder containing 3 subfolders and 4 files.

The first subfolder contains 5 files, the second one 14 and the third one just 1.

How can I collect all those files/file paths (4 + 5 + 14 + 1 = 24) in a single array?

Recursion.  You could adapt my ps_recursive_search function (modified by Gwendolyne) to return arrays of files instead of the count of files.

Ninjas... argent77's answer was better.

Edited by Sam.
Link to comment
Posted (edited)

@argent77

Your code takes into account only one level of subdirectory (since GET_DIRECTORY_ARRAY is called only once), whereas @Sam.'s function should work regardless of that (due to recursion).

However, I'm failing to edit it in order to collect file paths into a unique string / array, i.e.:

Spoiler


DEFINE_ACTION_FUNCTION ps_recursive_search
    STR_VAR ParentDir     = ""
            ChildDirRegex = ""
            FileRegex     = "^.+$"
    RET     FileList
BEGIN
	OUTER_SET Count = 0
 	OUTER_TEXT_SPRINT "FileList" ""
	ACTION_BASH_FOR ~%ParentDir%~ ~%FileRegex%~ BEGIN
		OUTER_SET Count += 1
  		OUTER_TEXT_SPRINT "FileList" "%FileList%,%BASH_FOR_FILESPEC%"
	END
	ACTION_CLEAR_ARRAY  ChildDir
	GET_DIRECTORY_ARRAY ChildDir ~%ParentDir%~ ~%ChildDirRegex%~
	ACTION_PHP_EACH ChildDir AS dirfrom => dirC BEGIN
		LAF ps_recursive_search STR_VAR ParentDir = EVAL "%dirC%" ChildDirRegex FileRegex RET "FileListN" = "FileList" END
		OUTER_SET Count += CountN
  		OUTER_TEXT_SPRINT "FileList" "%FileList%,%FileListN%"
	END

END

 

 

Edited by Luke
Link to comment

@Luke

If you just want a textual list, you could do:

Spoiler

DEFINE_ACTION_FUNCTION ps_recursive_search
    STR_VAR ParentDir     = ""
            ChildDirRegex = ""
            FileRegex     = "^.+$"
    RET     Count
            FileList
BEGIN

  OUTER_SET Count = 0
  OUTER_TEXT_SPRINT FileList ~~
  ACTION_BASH_FOR ~%ParentDir%~ ~%FileRegex%~ BEGIN
    OUTER_SET Count += 1
    OUTER_TEXT_SPRINT FileList ~%FileList%%WNL%%BASH_FOR_FILESPEC%~
  END
  ACTION_CLEAR_ARRAY  ChildDir
  GET_DIRECTORY_ARRAY ChildDir ~%ParentDir%~ ~%ChildDirRegex%~
  ACTION_PHP_EACH ChildDir AS dirfrom => dirC BEGIN
    LAF ps_recursive_search STR_VAR ParentDir = EVAL "%dirC%" ChildDirRegex FileRegex RET CountN = %Count% FileListN = %FileList% END
    OUTER_SET Count += CountN
    OUTER_TEXT_SPRINT FileList ~%FileList%%WNL%%FileListN%~
  END
  OUTER_INNER_PATCH_SAVE FileList ~%FileList%~ BEGIN
    REPLACE_TEXTUALLY ~\(%WNL%\)+~ ~%WNL%~
  END

END


LAF ps_recursive_search STR_VAR ParentDir = EVAL ~%MOD_FOLDER%~ RET FileList Count END
PRINT ~Count of files & folders found:  %Count%~
PRINT ~%FileList%~

If instead you want the function to return an array of files, see RET_ARRAY in the WeiDU docs.

Link to comment
Posted (edited)

@Sam.

That's exactly what I tried (the only difference is that I used "," in place of "%WNL%" to separate the various file paths), thanks for confirming it.

It didn't work for me because I launched the main function with ~ChildDirRegex = "^.+$"~ instead of using its default value (that is, the empty string "").

However, it seems I cannot target a specific subfolder (or more than one subfolder)...? I mean, if I write something like

LAF ps_recursive_search
STR_VAR
	ParentDir = EVAL ~%MOD_FOLDER%~
	ChildDirRegex = ~^\(test\|blah\)$~
RET
	FileList Count
END
PRINT ~Count of files & folders found:  %Count%~
PRINT ~%FileList%~

and both folders "%MOD_FOLDER%/test" and "%MOD_FOLDER%/blah" do exist, then only %MOD_FOLDER% is checked (the other two get ignored / skipped somehow...)

Edited by Luke
Link to comment

When I don't leave it blank, I have only given ChildDirRegex a raw name of a specific folder, like

ChildDirRegex = ~test~

Later I'll try and see why WeiDU isn't happy with actual RegEx.

Link to comment
21 minutes ago, Sam. said:

When I don't leave it blank, I have only given ChildDirRegex a raw name of a specific folder, like


ChildDirRegex = ~test~

 

Unfortunately, nothing changes...

Link to comment
9 hours ago, Luke said:

Unfortunately, nothing changes...

Alright, this one works for me.  Note I changed the function name as the functionality was expanded:

Spoiler

/* =================================================================================================================================================================== *
 *  FUNCTION ps_recursive_search_ex                                                                                                                                    *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *  This is a WeiDU action function that will recursively search into a parent directory and report how many files/directories that match the given RegEx are found.   *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *   INT_VAR                                                                                                                                                           *
 *      - IncludeFiles indicates whether files should be included in the returned Count and FileDirList.  0=NO | 1=YES                                                 *
 *      - IncludeDirs indicates whether directories should be included in the returned Count and FileDirList.  0=NO | 1=YES                                            *
 *      - IncludeParentFiles indicates whether files in ParentDir should be included in the returned Count and FileDirList.  0=NO | 1=YES                              *
 *   STR_VAR                                                                                                                                                           *
 *      - ParentDir is a string containing the name of the parent directory that will be recursively searched.                                                         *
 *      - ChildDirRegEx is a string containing the RegEx of child directories to search within ParentDir.                                                              *
 *      - FileRegex is a string containing the RegEx of files to match.                                                                                                *
 *      - Delimiter is a string containing the characters to use to delimit files/directories in FileDirList.                                                          *
 *   RET                                                                                                                                                               *
 *      - Count is the total count of files/directories found.                                                                                                         *
 *      - FileDirList is the Delimited list of files/directories found.                                                                                                *
 * =================================================================================================================================================================== */

DEFINE_ACTION_FUNCTION ps_recursive_search_ex
    INT_VAR IncludeFiles       = 1
            IncludeDirs        = 0
            IncludeParentFiles = 1
    STR_VAR ParentDir          = ""
            ChildDirRegEx      = ""
            FileRegEx          = "^.+$"
            Delimiter          = EVAL "%WNL%"
    RET     Count
            FileDirList
BEGIN

  OUTER_SET Count = 0
  OUTER_TEXT_SPRINT FileDirList ~~
  ACTION_IF (IncludeFiles = 1) AND (IncludeParentFiles = 1) BEGIN
    ACTION_BASH_FOR ~%ParentDir%~ ~%FileRegEx%~ BEGIN
      OUTER_SET Count += 1
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%BASH_FOR_FILESPEC%~
    END
  END
  ACTION_CLEAR_ARRAY  ChildDir
  GET_DIRECTORY_ARRAY ChildDir ~%ParentDir%~ ~%ChildDirRegEx%~
  ACTION_PHP_EACH ChildDir AS dirfrom => dirC BEGIN
    OUTER_SNPRINT "-1" LastChar ~%dirC%~
    ACTION_IF (~%LastChar%~ STRING_EQUAL_CASE ~.~ = 0) BEGIN
      ACTION_IF (IncludeDirs = 1) BEGIN
        OUTER_SET Count += 1
        OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%dirC%~
      END
      LAF ps_recursive_search_ex INT_VAR IncludeFiles IncludeDirs STR_VAR ParentDir = EVAL "%dirC%" ChildDirRegEx FileRegEx Delimiter RET CountN = %Count% FileDirListN = %FileDirList% END
      OUTER_SET Count += CountN
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%FileDirListN%~
    END
  END
  OUTER_INNER_PATCH_SAVE FileDirList ~%FileDirList%~ BEGIN
    REPLACE_TEXTUALLY ~\(%Delimiter%\)+~ ~%Delimiter%~
  END

END


LAF ps_recursive_search_ex INT_VAR IncludeFiles = 1 IncludeDirs = 0 IncludeParentFiles = 0 STR_VAR ParentDir = EVAL ~%MOD_FOLDER%~ ChildDirRegEx = ~^\(test\|blah\)$~ FileRegEx = ~^.+$~ RET FileDirList Count END
PRINT ~Count of files & directories found:  %Count%~
PRINT ~%FileDirList%~

Does this work for you?

Edited by Sam.
Link to comment
Posted (edited)
8 hours ago, Sam. said:

Alright, this one works for me.  Note I changed the function name as the functionality was expanded:

  Reveal hidden contents





/* =================================================================================================================================================================== *
 *  FUNCTION ps_recursive_search_ex                                                                                                                                    *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *  This is a WeiDU action function that will recursively search into a parent directory and report how many files/directories that match the given RegEx are found.   *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *   INT_VAR                                                                                                                                                           *
 *      - IncludeFiles indicates whether files should be included in the returned Count and FileDirList.  0=NO | 1=YES                                                 *
 *      - IncludeDirs indicates whether directories should be included in the returned Count and FileDirList.  0=NO | 1=YES                                            *
 *      - IncludeParentFiles indicates whether files in ParentDir should be included in the returned Count and FileDirList.  0=NO | 1=YES                              *
 *   STR_VAR                                                                                                                                                           *
 *      - ParentDir is a string containing the name of the parent directory that will be recursively searched.                                                         *
 *      - ChildDirRegEx is a string containing the RegEx of child directories to search within ParentDir.                                                              *
 *      - FileRegex is a string containing the RegEx of files to match.                                                                                                *
 *      - Delimiter is a string containing the characters to use to delimit files/directories in FileDirList.                                                          *
 *   RET                                                                                                                                                               *
 *      - Count is the total count of files/directories found.                                                                                                         *
 *      - FileDirList is the Delimited list of files/directories found.                                                                                                *
 * =================================================================================================================================================================== */

DEFINE_ACTION_FUNCTION ps_recursive_search_ex
    INT_VAR IncludeFiles       = 1
            IncludeDirs        = 0
            IncludeParentFiles = 1
    STR_VAR ParentDir          = ""
            ChildDirRegEx      = ""
            FileRegEx          = "^.+$"
            Delimiter          = EVAL "%WNL%"
    RET     Count
            FileDirList
BEGIN

  OUTER_SET Count = 0
  OUTER_TEXT_SPRINT FileDirList ~~
  ACTION_IF (IncludeFiles = 1) AND (IncludeParentFiles = 1) BEGIN
    ACTION_BASH_FOR ~%ParentDir%~ ~%FileRegEx%~ BEGIN
      OUTER_SET Count += 1
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%BASH_FOR_FILESPEC%~
    END
  END
  ACTION_CLEAR_ARRAY  ChildDir
  GET_DIRECTORY_ARRAY ChildDir ~%ParentDir%~ ~%ChildDirRegEx%~
  ACTION_PHP_EACH ChildDir AS dirfrom => dirC BEGIN
    OUTER_SNPRINT "-1" LastChar ~%dirC%~
    ACTION_IF (~%LastChar%~ STRING_EQUAL_CASE ~.~ = 0) BEGIN
      ACTION_IF (IncludeDirs = 1) BEGIN
        OUTER_SET Count += 1
        OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%dirC%~
      END
      LAF ps_recursive_search_ex INT_VAR IncludeFiles IncludeDirs STR_VAR ParentDir = EVAL "%dirC%" ChildDirRegEx FileRegEx Delimiter RET CountN = %Count% FileDirListN = %FileDirList% END
      OUTER_SET Count += CountN
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%FileDirListN%~
    END
  END
  OUTER_INNER_PATCH_SAVE FileDirList ~%FileDirList%~ BEGIN
    REPLACE_TEXTUALLY ~\(%Delimiter%\)+~ ~%Delimiter%~
  END

END


LAF ps_recursive_search_ex INT_VAR IncludeFiles = 1 IncludeDirs = 0 IncludeParentFiles = 0 STR_VAR ParentDir = EVAL ~%MOD_FOLDER%~ ChildDirRegEx = ~^\(test\|blah\)$~ FileRegEx = ~^.+$~ RET FileDirList Count END
PRINT ~Count of files & directories found:  %Count%~
PRINT ~%FileDirList%~

Does this work for you?

Yes and no...

I mean, your code still fails if "test" and "blah" contain subfolders (no file will be returned...)

So basically the "ChildDirRegEx" variable is somewhat useless...? That is, you cannot recursively search into specific subdirectories if these subdirectories contain other directories...

On the other hand, if "ChildDirRegEx" is set to the empty string "", then everything will be returned...

So to sum up, you're somewhat forced to do something like

Spoiler

ACTION_FOR_EACH "subdir" IN "test" "blah" BEGIN
	LAF ps_recursive_search_ex
	INT_VAR
		IncludeFiles = 1
		IncludeDirs = 0
		IncludeParentFiles = 0
	STR_VAR
		ParentDir = EVAL ~%MOD_FOLDER%/%subdir%~
		//ChildDirRegEx = ~^\(test\|blah\)$~
		FileRegEx = ~^.+$~
	RET
		FileDirList
		Count
	END
	PRINT ~Count of files & directories found:  %Count%~
	PRINT ~%FileDirList%~
END

 

 

Edited by Luke
Link to comment
6 hours ago, Luke said:

Yes and no...

I mean, your code still fails if "test" and "blah" contain subfolders (no file will be returned...)

So basically the "ChildDirRegEx" variable is somewhat useless...? That is, you cannot recursively search into specific subdirectories if these subdirectories contain other directories...

On the other hand, if "ChildDirRegEx" is set to the empty string "", then everything will be returned...

So to sum up, you're somewhat forced to do something like

  Reveal hidden contents


ACTION_FOR_EACH "subdir" IN "test" "blah" BEGIN
	LAF ps_recursive_search_ex
	INT_VAR
		IncludeFiles = 1
		IncludeDirs = 0
		IncludeParentFiles = 0
	STR_VAR
		ParentDir = EVAL ~%MOD_FOLDER%/%subdir%~
		//ChildDirRegEx = ~^\(test\|blah\)$~
		FileRegEx = ~^.+$~
	RET
		FileDirList
		Count
	END
	PRINT ~Count of files & directories found:  %Count%~
	PRINT ~%FileDirList%~
END

 

 

After some thought I've realized the function was doing what it claimed to but that it was unlikely to be returning the results you might expect.  Specifically, ChildDirRegEx was being passed to the inner function call meaning only files matching FileRegEx contained within a directory matching ChildDirRegEx AT EACH DIRECTORY LEVEL were being returned.

Thus if you had

\MOD_FOLDER
  \blah
    file1.txt
    file2.txt
    \blah
      file3.txt
      file4.txt
    \somedir
      file5.txt
      file6.txt

file5.txt and file6.txt wouldn't be returned because they weren't in a folder matching ChildDirRegEx at that level.  This version of the function only matches ChildDirRegEx at the top level within ParentDir, and then recurses through all directories as it goes deeper:

Spoiler

/* =================================================================================================================================================================== *
 *  FUNCTION ps_recursive_search_ex                                                                                                                                    *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *  This is a WeiDU action function that will recursively search into a parent directory and report how many files/directories that match the given RegEx are found.   *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *   INT_VAR                                                                                                                                                           *
 *      - IncludeFiles indicates whether files should be included in the returned Count and FileDirList.  0=NO | 1=YES                                                 *
 *      - IncludeDirs indicates whether directories should be included in the returned Count and FileDirList.  0=NO | 1=YES                                            *
 *      - IncludeParentFiles indicates whether files in ParentDir should be included in the returned Count and FileDirList.  0=NO | 1=YES                              *
 *   STR_VAR                                                                                                                                                           *
 *      - ParentDir is a string containing the name of the parent directory that will be recursively searched.                                                         *
 *      - ChildDirRegEx is a string containing the RegEx of child directories to search within ParentDir.                                                              *
 *      - FileRegex is a string containing the RegEx of files to match.                                                                                                *
 *      - Delimiter is a string containing the characters to use to delimit files/directories in FileDirList.                                                          *
 *   RET                                                                                                                                                               *
 *      - Count is the total Count of files/directories found.                                                                                                         *
 *      - FileDirList is the Delimited list of files/directories found.                                                                                                *
 *   Last Updated 20210416                                                                                                                                             *
 * =================================================================================================================================================================== */

DEFINE_ACTION_FUNCTION ps_recursive_search_ex
    INT_VAR IncludeFiles       = 1
            IncludeDirs        = 0
            IncludeParentFiles = 1
    STR_VAR ParentDir          = ""
            ChildDirRegEx      = ""
            FileRegEx          = "^.+$"
            Delimiter          = EVAL "%WNL%"
    RET     Count
            FileDirList
BEGIN

  OUTER_SET Count = 0
  OUTER_TEXT_SPRINT FileDirList ~~
  ACTION_IF (IncludeFiles = 1) AND (IncludeParentFiles = 1) BEGIN
    ACTION_BASH_FOR ~%ParentDir%~ ~%FileRegEx%~ BEGIN
      OUTER_SET Count += 1
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%BASH_FOR_FILESPEC%~
    END
  END
  ACTION_CLEAR_ARRAY  ChildDir
  GET_DIRECTORY_ARRAY ChildDir ~%ParentDir%~ ~%ChildDirRegEx%~
  ACTION_PHP_EACH ChildDir AS dirfrom => dirC BEGIN
    OUTER_SNPRINT "-1" LastChar ~%dirC%~
    ACTION_IF (~%LastChar%~ STRING_EQUAL_CASE ~.~ = 0) BEGIN
      ACTION_IF (IncludeDirs = 1) BEGIN
        OUTER_SET Count += 1
        OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%dirC%~
      END
      LAF ps_recursive_search_ex INT_VAR IncludeFiles IncludeDirs IncludeParentFiles = 1 STR_VAR ParentDir = EVAL "%dirC%" ChildDirRegEx = "" FileRegEx Delimiter RET CountN = %Count% FileDirListN = %FileDirList% END
      OUTER_SET Count += CountN
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%FileDirListN%~
    END
  END
  OUTER_INNER_PATCH_SAVE FileDirList ~%FileDirList%~ BEGIN
    REPLACE_TEXTUALLY ~\(%Delimiter%\)+~ ~%Delimiter%~
  END

END

 

 

Link to comment
17 hours ago, Sam. said:

After some thought I've realized the function was doing what it claimed to but that it was unlikely to be returning the results you might expect.  Specifically, ChildDirRegEx was being passed to the inner function call meaning only files matching FileRegEx contained within a directory matching ChildDirRegEx AT EACH DIRECTORY LEVEL were being returned.

Thus if you had


\MOD_FOLDER
  \blah
    file1.txt
    file2.txt
    \blah
      file3.txt
      file4.txt
    \somedir
      file5.txt
      file6.txt

file5.txt and file6.txt wouldn't be returned because they weren't in a folder matching ChildDirRegEx at that level.  This version of the function only matches ChildDirRegEx at the top level within ParentDir, and then recurses through all directories as it goes deeper:

  Reveal hidden contents


/* =================================================================================================================================================================== *
 *  FUNCTION ps_recursive_search_ex                                                                                                                                    *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *  This is a WeiDU action function that will recursively search into a parent directory and report how many files/directories that match the given RegEx are found.   *
 * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- *
 *   INT_VAR                                                                                                                                                           *
 *      - IncludeFiles indicates whether files should be included in the returned Count and FileDirList.  0=NO | 1=YES                                                 *
 *      - IncludeDirs indicates whether directories should be included in the returned Count and FileDirList.  0=NO | 1=YES                                            *
 *      - IncludeParentFiles indicates whether files in ParentDir should be included in the returned Count and FileDirList.  0=NO | 1=YES                              *
 *   STR_VAR                                                                                                                                                           *
 *      - ParentDir is a string containing the name of the parent directory that will be recursively searched.                                                         *
 *      - ChildDirRegEx is a string containing the RegEx of child directories to search within ParentDir.                                                              *
 *      - FileRegex is a string containing the RegEx of files to match.                                                                                                *
 *      - Delimiter is a string containing the characters to use to delimit files/directories in FileDirList.                                                          *
 *   RET                                                                                                                                                               *
 *      - Count is the total Count of files/directories found.                                                                                                         *
 *      - FileDirList is the Delimited list of files/directories found.                                                                                                *
 *   Last Updated 20210416                                                                                                                                             *
 * =================================================================================================================================================================== */

DEFINE_ACTION_FUNCTION ps_recursive_search_ex
    INT_VAR IncludeFiles       = 1
            IncludeDirs        = 0
            IncludeParentFiles = 1
    STR_VAR ParentDir          = ""
            ChildDirRegEx      = ""
            FileRegEx          = "^.+$"
            Delimiter          = EVAL "%WNL%"
    RET     Count
            FileDirList
BEGIN

  OUTER_SET Count = 0
  OUTER_TEXT_SPRINT FileDirList ~~
  ACTION_IF (IncludeFiles = 1) AND (IncludeParentFiles = 1) BEGIN
    ACTION_BASH_FOR ~%ParentDir%~ ~%FileRegEx%~ BEGIN
      OUTER_SET Count += 1
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%BASH_FOR_FILESPEC%~
    END
  END
  ACTION_CLEAR_ARRAY  ChildDir
  GET_DIRECTORY_ARRAY ChildDir ~%ParentDir%~ ~%ChildDirRegEx%~
  ACTION_PHP_EACH ChildDir AS dirfrom => dirC BEGIN
    OUTER_SNPRINT "-1" LastChar ~%dirC%~
    ACTION_IF (~%LastChar%~ STRING_EQUAL_CASE ~.~ = 0) BEGIN
      ACTION_IF (IncludeDirs = 1) BEGIN
        OUTER_SET Count += 1
        OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%dirC%~
      END
      LAF ps_recursive_search_ex INT_VAR IncludeFiles IncludeDirs IncludeParentFiles = 1 STR_VAR ParentDir = EVAL "%dirC%" ChildDirRegEx = "" FileRegEx Delimiter RET CountN = %Count% FileDirListN = %FileDirList% END
      OUTER_SET Count += CountN
      OUTER_TEXT_SPRINT FileDirList ~%FileDirList%%Delimiter%%FileDirListN%~
    END
  END
  OUTER_INNER_PATCH_SAVE FileDirList ~%FileDirList%~ BEGIN
    REPLACE_TEXTUALLY ~\(%Delimiter%\)+~ ~%Delimiter%~
  END

END

 

 

Nice, it's better now, thanks a lot for your help!

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

×
×
  • Create New...