Category Archives: Windows

Looping in folders, running the tool….

… was given a tool, xmlviewer, for the linguists to view and check the XML Help files. This tool, however, can only view a XML file each time… So to check the files, we have to open one file at a time… and the worst scenario is… given a set of 200 over XML files that are stored separately in sub-folders of the main one… Open a file at a time will take ages to complete… not including to search for the files in the sub-folders… and if you forget where you have stopped.. you have to start all over again…

…Therefore, I decide to create a batch file to loop all the folders and run tool everytime they found xml files..

FOR /F "usebackq delims= " %%i IN (`dir *.xml /B /S`) DO xmlviewer.exe %%~i

The batch file will loop through the folders and open the xml files one at a time… Once you close the XML file you are viewing… It will open the next XML file.. this will carry on until all XML files are viewed…

Looking at the code, the keywords,

useback>q specifies that the codes in the backquote is executed as a command… and…
delims=xxx specifies the delimiter set.


Follow

Get every new post delivered to your Inbox.