0

I need a Batch FOR loop that iterates through the driveletters of NTFS drives only.

I found a way to do a FOR loop like so:

for %%X in (C:\ D:\ E:\ F:\ G:\) do <bla>

Obviously I could go A-Z to get all drives, however, how can I enforce that it only goes through NTFS drives and not FAT32, CDFS, etc.?

Can I build in a check somehow or generate the array of driveletters beforehand?

Yes, it has to be Windows Batch DOS, so no powershell, vbscript or other languages please.

3
for /f %%A in ('wmic logicaldisk where "FileSystem='NTFS'" get name') do ...

Note that the values in %%A will not include the backslash. They will look like C:, D:, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.