Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get all QMitem in the folder where the current macro
#3
Can anyone help? Thank you very much.  

I even thought about using PowerShell to implement the above functionality.  Big Grin

It would be great if the GQIN_Enum function in the following link could be improved to output the full path, such as [Folder]\[Folder]\qmitemName.
https://www.libreautomate.com/forum/show...6#pid17056
 
Code:
Copy      Help
$lines = @'
[Folder]
.A
.B
.[Folder]
..C
..D
Macro18
Macro17
'@ -split "`r`n"

# Stack for tracking the current multi-level directory
$stack = @()

foreach ($line in $lines) {
    $trimmed = $line.Trim()
    if ($trimmed -eq "") { continue }

    # Determine the number of dots
    if ($trimmed -match '^(\.+)(.+)$') {
        $level = $Matches[1].Length
        $name = $Matches[2].Trim()

        # Ensure the stack depth matches the level; pop if too deep, keep if less
        if ($stack.Count -gt $level) {
            $stack = $stack[0..($level-1)]
        }

        # If it's a folder (starts with dots and [xxx]), push to stack and output
        if ($name -match '^\[(.+)\]$') {
            $stack += $Matches[0]
            Write-Output ($stack -join '\')
        } else {
            # Regular file, output full path directly
            Write-Output (($stack -join '\') + "\" + $name)
        }
        continue
    }

    # Top-level folder, reset stack
    if ($trimmed -match '^\[(.+?)\]$') {
        $stack = @($Matches[0])
        Write-Output $trimmed
        continue
    }

    # Regular top-level item (no indentation)
    Write-Output $trimmed
}


Messages In This Thread
RE: Get all QMitem in the folder where the current macro - by Davider - 06-30-2025, 02:17 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)