O
O
ooHikeoo2016-08-09 10:09:09
cmd/bat
ooHikeoo, 2016-08-09 10:09:09

Display in one specific folder the names of folders with name length =2?

help you need: for zabix, output so that he reads and understands
Display in one specific folder the names of folders with name length = 2
you need to display like this:
{
"data":[
{
"{#LOGNAME}":"og"
},
{
" {#LOGNAME}":"og"
},
{
"{#LOGNAME}":"og"
}
]
}
but instead of og my folders

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-08-09
@yellowmew

well, by tradition, the solution is in powershell :D

[email protected]{"data"=""}
$data.data=(get-childitem c:\test -directory | where {$_.name.Length -eq 2} | Select @{name='{#LOGNAME}';expression={$_.name}}
$data | convertto-json | out-file c:\test\json.json

O
ooHikeoo, 2016-08-09
@ooHikeoo

The topic can be closed thanks to everyone, if anything, here is my script:
@echo off&::
Setlocal EnableDelayedExpansion
Set B=
echo {
echo "data":[
echo {
Set /a C=0
For /F %%A in ('dir /b E:\testt\??') do (
set B=%%A
if not "!C!"=="0" (
echo },
echo {
)
set /a C=!C!+1
echo "{# LOGNAME}":"!B!"
)
echo }
echo ]
echo }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question