Mekrel Posted February 28, 2005 Share Posted February 28, 2005 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 driveThe 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 More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 how about giving this a try...for /f "tokens=3 delims=) " %i IN ('dir ^| find "bytes free"') DO ECHO %iRemember, if you are using it in a batch file you will need to change the %i to %%iDo you need the commas removed? Link to comment Share on other sites More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 Or better yet...for /f "tokens=3 delims=) " %%i IN ('c:\ dir ^| find "bytes free"') DO SET freespace=%%ifor /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%mThen just call the variable %freespace% and it will be the number of bytes without commas Link to comment Share on other sites More sharing options...
Mekrel Posted February 28, 2005 Author Share Posted February 28, 2005 Hi mate i tried to run the later script you gave from a .cmd file but got 'c:\' is not recognized as an internal or external command,operable program or batch file. Many thanks though Link to comment Share on other sites More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 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=%%ifor /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%m Link to comment Share on other sites More sharing options...
ravashaak Posted February 28, 2005 Share Posted February 28, 2005 Alternately, you could try the PSInfo utility from Sysinternals:http://www.sysinternals.com/ntw2k/freeware/psinfo.shtml - Ravashaak Link to comment Share on other sites More sharing options...
Mekrel Posted February 28, 2005 Author Share Posted February 28, 2005 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=%%ifor /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%m<{POST_SNAPBACK}>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\" /sit 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 Link to comment Share on other sites More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 set checkpath=C:\recorded tvs\for /f "tokens=3 delims=) " %%i IN ('dir %checkpath% ^| find "bytes free"') DO SET freespace=%%ifor /f "tokens=1-5" %%i IN ('echo %freespace%') DO set freespace=%%i%%j%%k%%l%%mThat should do the trick for you Link to comment Share on other sites More sharing options...
Mekrel Posted February 28, 2005 Author Share Posted February 28, 2005 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=%%ifor /f "tokens=1-5" %%i IN ('echo %usedspace%') DO set usedspace=%%i%%j%%k%%l%%mnope 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 More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 set checkpath=C:\recorded tvs\for /f "tokens=4 delims=) " %%i IN ('dir %checkpath% ^| find "bytes" ^| find /n "free"') DO SET usedspace=%%ifor /f "tokens=1-5" %%i IN ('echo %usedspace%') DO set usedspace=%%i%%j%%k%%l%%mnotice the edition in red. That should do the trick Link to comment Share on other sites More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 If you use only the search string of "bytes" it will return 2 lines and run the FOR statement on each line. That's why I added the second find string to remove the line including "free" Link to comment Share on other sites More sharing options...
Mekrel Posted February 28, 2005 Author Share Posted February 28, 2005 bah didnt work its still returning the free drive space , so i guess this is the end of the road?Many thank again anyway m8 Link to comment Share on other sites More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 No... it should be returning the space used. make sure you have the /n on the second find string. Link to comment Share on other sites More sharing options...
un4given1 Posted February 28, 2005 Share Posted February 28, 2005 OK. here. Ignore all else. I made a mistake. it's /v not /nset checkpath=C:\recorded tvs\for /f "tokens=3 delims=) " %%i IN ('dir %checkpath% ^| find "bytes" ^| find /v "free"') DO SET usedspace=%%ifor /f "tokens=1-5" %%i IN ('echo %usedspace%') DO set usedspace=%%i%%j%%k%%l%%mI 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 More sharing options...
Mekrel Posted February 28, 2005 Author Share Posted February 28, 2005 Great! it worked but only after I added /S after %checkpath% to check for subdirectories, thanks mate your a star! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now