Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7750975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:25:49+00:00 2026-06-01T11:25:49+00:00

Yesterday I had seen question concerning how to get file space information. I tried

  • 0

Yesterday I had seen question concerning how to get file space information. I tried command like this:

FOR /F %%A IN (‘dir c:\ ^| findstr /rc:Adr’) DO
echo A:”%%A”B:”%%B”C:”%%C”D:”%%D”

I thought it could be possible to extract last line, starting in my local language by “Adr”, yours probably “Directory”. It is not exactly the same because yesterday I got as output result the command itself: dir c:\ ^| findstr /rc:Adr. Now I test it again in CMD and got this:

C:\>FOR %A IN (dir c:\ ^| findstr /rc:Adr) Do Echo A:"%A"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"dir"B:"%B"C:"%C"D:"%D"
A:"dir"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"c:\"B:"%B"C:"%C"D:"%D"
A:"c:\"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"|"B:"%B"C:"%C"D:"%D"
A:"|"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"findstr"B:"%B"C:"%C"D:"%D"
A:"findstr"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"/rc:Adr"B:"%B"C:"%C"D:"%D"
A:"/rc:Adr"B:"%B"C:"%C"D:"%D"

C:\>FOR %A IN ('dir c:\ ^| findstr /rc:Adr') Do Echo A:"%A"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"'dir"B:"%B"C:"%C"D:"%D"
A:"'dir"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"c:\"B:"%B"C:"%C"D:"%D"
A:"c:\"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"|"B:"%B"C:"%C"D:"%D"
A:"|"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"findstr"B:"%B"C:"%C"D:"%D"
A:"findstr"B:"%B"C:"%C"D:"%D"

C:\>Echo A:"/rc:Adr'"B:"%B"C:"%C"D:"%D"
A:"/rc:Adr'"B:"%B"C:"%C"D:"%D"

C:\>dir c:\ | findstr /rc:Adr
           Adresářů:     6,   Volných bajtů:  1 447 161 856

C:\>

Next situation that I have problem with:
If I want to print filenames:

@Echo off
FOR  %%F IN (dir *.inf) DO (
echo %%F
)

First item in the output is dir and then the files. What I do wrong not to obtain the command itself, but the data I requested?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:25:50+00:00Added an answer on June 1, 2026 at 11:25 am

    To iterate through lines returned by another command you need to use for command with /f switch. Take a look at for /? for detailed information.

    To obtain the amount of free disk space on a computer with Chech version of Windows, use:

    for /f "tokens=4,*" %%A in ('dir c:\ ^| findstr /rc:Adr') do echo %%B

    If you want a language-independant solution, use:

    for /f "delims== tokens=2" %%A in ('wmic volume where "DriveLetter='C:'" get FreeSpace /value') do echo %%A
    

    In the second case, you can omit the dir command and iterate through files directly:

    for %%A in (*.inf) do echo %%A

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw some code yesterday in this question that I had not seen before,
Seems like just yesterday I had this same problem with Play! v1. After trying
This question has two parts. Part 1. Yesterday I had some code which would
I had this code working yesterday, but it seems like I edited it a
If you haven't seen my question yesterday, this is my second rails app. The
I had this question on an Algorithms test yesterday, and I can't figure out
Yesterday I had a failing darcs install with cabal, today I get this when
This is kind of a followup to the question I had yesterday. I had
Yesterday i asked this question: Get current time and set a value in a
This is a continuation from a question that I had yesterday. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.