R
Rojo Habe
I'm trying to schedule a task to analyse a volume and then go ahead and
defrag it if necessary (i.e. if it's fragmented past a certain threshold).
There is no command line switch for defrag.exe that will do this in one hit
so I need to write a script:
defrag <volume> /a
if [disk needs defragging] then
defrag <volume>
Unfortunately I know nothing the syntax required so I was hoping someone out
there could help me out with the middle line. I'll be happy just to test
for the text "You should defrag this volume." I'm assuming the easiest way
to perform this test would be to write the fragmentation report to a text
file, i.e. the first line would read:
defrag <volume> /a >defrag.txt
or something similar, and then the next line would be searching this file
for a specific string to determine whether or not to execute line 3.
Or am I overcomplicating things here?
defrag it if necessary (i.e. if it's fragmented past a certain threshold).
There is no command line switch for defrag.exe that will do this in one hit
so I need to write a script:
defrag <volume> /a
if [disk needs defragging] then
defrag <volume>
Unfortunately I know nothing the syntax required so I was hoping someone out
there could help me out with the middle line. I'll be happy just to test
for the text "You should defrag this volume." I'm assuming the easiest way
to perform this test would be to write the fragmentation report to a text
file, i.e. the first line would read:
defrag <volume> /a >defrag.txt
or something similar, and then the next line would be searching this file
for a specific string to determine whether or not to execute line 3.
Or am I overcomplicating things here?