I am doing some maintenance scripts and want to get defragment status like this:
@echo off setlocal EnableExtensions defrag c: -a & gt;% for TEMP% \ defrag_c_fixed.txt / f "skip = 4 delims =, (tokens = 4" %% (% TEMP% \ defrag_c_fixed.txt) Set for fragment = %% a for / f "skip = 5 tokens = *" %% a in (% TEMP% \ defrag_c_fixed.txt) Recommend = %% one echo! Piece! Echo! Recommended! Pause
I am getting the state of the composition with the empty space at the beginning of the numbers:
20% Croping You should defragge this volume .. Press any key to continue ...
How do I delete it from the script?
You can use the / F to strip key locations. Using TOKENS = * the delimiter delimiter will stretch, and the default delimiter space And tabs.
for / f "token = *" in %% ("! Piece! ") What echo (%% A
Comments
Post a Comment