[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

a dos batch command

Posted on 2011-03-15
5
Medium Priority
?
357 Views
Last Modified: 2012-06-27
Can you explain the code?
for /f %%c in ('"dir /b:d"') do %GZIP% %%c\*.txt

Open in new window


Thank you.
0
Comment
Question by:zhshqzyc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:meb_santoso
ID: 35141281
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
 

Author Comment

by:zhshqzyc
ID: 35141459
Sorry, typo.
for /f %%c in ('"dir /b /a:d"') do %GZIP% %%c\*.txt

Open in new window

0
 
LVL 13

Expert Comment

by:5g6tdcv4
ID: 35141669
/b is bare
/a:d is attributes only show directories
0
 
LVL 5

Accepted Solution

by:
meb_santoso earned 500 total points
ID: 35141781
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
 
LVL 13

Expert Comment

by:5g6tdcv4
ID: 35141806
Men has the answer :-)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question