a dos batch command

Can you explain the code?
for /f %%c in ('"dir /b:d"') do %GZIP% %%c\*.txt

Open in new window


Thank you.
zhshqzycAsked:
Who is Participating?
 
meb_santosoConnect With a Mentor Commented:
in that case:

breaking it down:
-. dir /b /a:d will list all directories within a certain path in bare (plain) formatting, i.e. no heading information or summary
-. FOR <variable> IN <set> do <action> : will execute <action> for each file in a set of files based on the parameters

Everything in one place:
process all .txt files into an archive using gzip for every *.txt files within directories that listed from the command dir according to the variable %%c.

Why %%c? Because you are utilizing the variable in a batch file.
0
 
meb_santosoCommented:
for /f %%c in ('"dir /b:d"') do %GZIP% %%c\*.txt

Open in new window


do archive every files that has the extension .txt for every given file listed from the command dir /b according to the variable %%c.

gzip is a program / operation to archive file. the %GZIP% is a parameter / routine / process defined elsewhere.

I don't know what's parameter /b:d in the dir command, as far as I know there is no such parameter. /b will output bare formatting of the files in the respective directory, but :d (colon d) is unknown.

%%c is a self defined parameter, it can be anything.
0
 
zhshqzycAuthor Commented:
Sorry, typo.
for /f %%c in ('"dir /b /a:d"') do %GZIP% %%c\*.txt

Open in new window

0
 
5g6tdcv4Commented:
/b is bare
/a:d is attributes only show directories
0
 
5g6tdcv4Commented:
Men has the answer :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.