Something like this?
FOR /F "usebackq tokens=1 skip=4" %i IN (`net file`) DO net file %i /close
if you use it inside cmd file replace both %i with %%i.
and remember that ` is backquite - this one before 1 key in the topmost row of the keyboard.
And I still would like to warn you before you destroy your user data...