Jump to content

Looking For A Command Line Util


Mekrel

Recommended Posts

Hi ive googled this, but only come up with freedisk which is for windows 2000.

Im looking for a console util which i can run to see if free space is left on the drive

The reason for this is someone has asked for a script which moves files according to thier drives states, and i fancy trying to help whilst trying to learn more about cmd.exe :)

Link to comment
Share on other sites


Or better yet...

for /f "tokens=3 delims=) " %%i IN ('c:\ dir ^| find "bytes free"') DO SET freespace=%%i
for /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%m

Then just call the variable %freespace% and it will be the number of bytes without commas

Link to comment
Share on other sites

HAHA... try switching that around. I typed it wrong. dir c:\ (or use place the driver letter you want)

for /f "tokens=3 delims=) " %%i IN ('dir c:\ ^| find "bytes free"') DO SET freespace=%%i
for /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%m

Link to comment
Share on other sites

HAHA... try switching that around.  I typed it wrong.  dir c:\  (or use place the driver letter you want)

for /f "tokens=3 delims=) " %%i IN ('dir c:\ ^| find "bytes free"') DO SET freespace=%%i
for /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%m

Thanks un4given1, very kind of you.

Im trying to help someone, and ive got some basic stuff working but kind of ran into a problem.

So far im checking each drive to see if it has at least 1GB of space free, now this is a problem if the TV progs he has recorded using his tv card adds up to more than 1GB of data.

So i was thinking i need to create a variable to read how many files he has in C:\recorded tvs\.

Now i know if I run

DIR "C:\recorded tvs\" /s

it does give me a value of the total byte size that the files add up to in C:\recorded tvs and all its sub directories, i just dont know how to get that information! into a variable :(

Then i can just check if the drive has at least the space that C:\recorded has, if not check the next disk and copy them there, or go onto the next disk etc.

Thanks yet again, also could you use some comment tags or someething to explain whats happening. Like i said i want to learn :D

post-36735-1109616251_thumb.jpg

Link to comment
Share on other sites

Thanks again, really appreciate your help here, obviously i will be linking to the thread to give full credit where is due.

but, for C:\recorded tvs, i need to find the used space this time, not the free space, so would it be:

set checkpath=C:\recorded tvs\
for /f "tokens=3 delims=) " %%i IN ('dir %checkpath% ^| find "bytes"') DO SET usedspace=%%i
for /f "tokens=1-5" %%i IN ('echo %usedspace%') DO set usedspace=%%i%%j%%k%%l%%m

nope that didnt do what i needed, it still shown the free bytes, is that because bytes is global and used in both:

"free bytes" and "bytes"?

Link to comment
Share on other sites

set checkpath=C:\recorded tvs\

for /f "tokens=4 delims=) " %%i IN ('dir %checkpath% ^| find "bytes" ^| find /n "free"') DO SET usedspace=%%i

for /f "tokens=1-5" %%i IN ('echo %usedspace%') DO set usedspace=%%i%%j%%k%%l%%m

notice the edition in red. That should do the trick

Link to comment
Share on other sites

OK. here. Ignore all else. I made a mistake. it's /v not /n

set checkpath=C:\recorded tvs\
for /f "tokens=3 delims=) " %%i IN ('dir %checkpath% ^| find "bytes" ^| find /v "free"') DO SET usedspace=%%i
for /f "tokens=1-5" %%i IN ('echo %usedspace%') DO set usedspace=%%i%%j%%k%%l%%m

I also changed the tokens back to 3, not 4... if you don't make that change you will get "bytes" back

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...