kolche Posted August 3, 2009 Posted August 3, 2009 I have a few partitions and i wanna to know is it possible cmd to check them for files exist. The target is simple - if partition is empty, after the check cmd script to relocate program files and documents and settings, or if partition is full to check next partition while find a empty partition? How i can check files exist on partition from cmd? Is it possible to integrate if exist similar script in to cmd script wich i can relocate program files and documents and settings directories to other partition?
Yzöwl Posted August 3, 2009 Posted August 3, 2009 You would probably need to check for files or directories not assigned system attributes on mounted fixed drives.Notice that I said fixed, the last thing you'd want is for a removable device to accidentally get filled with data.I would therefore suggest that you require a batch file which uses cscript or a fully fledged vbscript.Untested.cmd@Echo off&Setlocal enableextensions>"%Temp%\_$.vbs" (Echo strComputer = "." Echo Set objWMIService = GetObject("winmgmts:" _ Echo ^& "{impersonationLevel=impersonate}!\\" ^& strComputer ^&^ "\root\cimv2"^) Echo Set colDrives = objWMIService.ExecQuery _ Echo ("Select * from Win32_LogicalDisk where DriveType = '3'"^) Echo For Each objDrive in colDrives Echo wsh.echo objDrive.DeviceID Echo Next)For /f %%a In ('cscript //nologo "%Temp%\_$.vbs"') Do Call :C_ %%aDel "%Temp%\_$.vbs"Goto :Eof:C_Dir/b/a-ds %1\ >Nul 2>&1&&(Goto :Eof)If Defined _ (Goto :Eof) Else (Set _=T)Echo REM Code goes below here for empty drive [%1] found
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