Posts: 1,154
Threads: 268
Joined: Jul 2022
I want to get all QMitem in the folder where the current macro. If there are multiple folders with the same name, only the projects under the parent folder should be retrieved.
demo:
https://i.ibb.co/G4G9WCzp/demo.gif
How to get the folder path in the format like "\Folder\Folder"?
Macro
C
out
QMITEM qi
qmitem("" 0 &qi)
str folderName.getmacro(qi.folderid 1)
out folderName
ARRAY(QMITEMIDLEVEL) a; int i
GetQmItemsInFolder(folderName &a 1)
for i 0 a.len
,out _s.getmacro(a[i].id 1)
Posts: 1,154
Threads: 268
Joined: Jul 2022
06-29-2025, 10:50 PM
(This post was last modified: 06-29-2025, 11:24 PM by Davider.)
The following qm code can generate the following file hierarchy after execution.
[Folder]
.A
.B
.[Folder]
..C
..D
Macro18
Macro17
How to generate a file hierarchy like this? It seems that this file structure could solve my problem(
I can search for \qmitemName to find the folder where it is located).
[Folder]
[Folder]\A
[Folder]\B
[Folder]\[Folder]
[Folder]\[Folder]\C
[Folder]\[Folder]\D
Macro18
Macro17
Link:
https://www.libreautomate.com/forum/show...6#pid17056
Macro
GetQmItemNames_T
out
str s
GetQmItemNames "" s
out s
The following post is similar to the problem I encountered.
https://www.libreautomate.com/forum/show...p?tid=4612
Posts: 1,154
Threads: 268
Joined: Jul 2022
06-30-2025, 02:17 AM
(This post was last modified: 06-30-2025, 02:22 AM by Davider.)
Can anyone help? Thank you very much.
I even thought about using PowerShell to implement the above functionality.
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
$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
}