hi, Im trying to use find command to get paths of containers. But I want do not wish a list of all containers within. I wish a list of containers within certain levels…For example,
out of:
/food/fruits/apples
/food/fruits/apples/red_apples
/food/fruits/oranges
/food/veggies/beets
I wish only list of:
/food/fruits/apples
/food/fruits/oranges
Markus recommended using something like argxc after using “find -t COMP: /food/fruits”. But I am not sure what argxc does… could anyone suggest how I can get a list of these?
My purpose is to oppaste a DAT script to all containers on a specific level, but none inside… Thanks!
set fruits = `execute("find -e COMP:container /food/fruits/*")`
returns you a list with 3 entries - now the thinking behind the expression “argxc” is, that it returns you: (also see exhelp for that)
Now you can see the “/” in the names of the container as a separator. So with your example, 2 of the returned strings will have 3 “/” and one will have 4 which is the one you don’t want.
So you pass your list through a foreach-loop and every time check with argxc if the string has the same amount of “/” as your original folder. If not - you throw it out…
Here is a complete script with output into a table:
table /result 0 0 ""
set folder = /food/fruits/*
set fruits = `execute("find -e COMP:container $folder")`
foreach fruit($fruits)
if (`argxc("$fruit","/")`==`argxc("$folder","/")`)
echo $fruit >> DAT:/result
endif
end
Nice solution markus. Much better than my idea. Anyway, having to parse is fine for more complicated stuff, but imho finding ops should be possible without it. So can’t we just get a switch for the find command which makes it only search at the supplied “level”? Or make it depend on the presence off “*” at the end of the search string?
find -e COMP:container /food/fruits/*
looks also in subfolders
find -e COMP:container /food/fruits
only looks in /food/fruits
Thanks Markus, it works well. But out of curiosity, is there a command that will list “current selected node” of the network level being viewed? like MEL’s, “ls -sl”. Basically I have hundreds of buttons in a container that I had to put in a DAT:text with scripts. And those button containers have containers inside as well, which I don’t need the DAT:text to be in… Also, not all COMP:buttons needed the scripts inside, only the ones in a certain coordinant area… so I had to write another script that selects only certain coordinants…
With listing the selection, I could just drag select the area i want with icons. Then put the list output into a variable quite easily.
going into any network node, and $CURRENT will return the child of that node that is current (opset -c), and $SELECTED will return a list of all nodes that are selected (opset -p).