InterviewSolution
Saved Bookmarks
| 1. |
Solve : How to modify this for loop:? |
|
Answer» Quote from: PPowerHouseK on October 16, 2009, 12:22:41 PM
C:\>type list2.txt house1.map house1.map.zip house2.map house2.map.zip house3.map house3.map.zip house4.map house4.map.zip C:\>type zip.bat Code: [Select]@echo off findstr /v "zip" list2.txt C:\> zip.bat house1.map house2.map house3.map house4.map C:\> Well it now works perfectly. Thanks guys that did just the trick. Special thanks to Bill and Salmon! You guys Rock! I used Bill's code with Salmon's first adjustment. I suppose this can be marked as SOLVED. PPowerHouseK wrote: "When the function lists the files in a text, it lists alphabetically alternating the .map and .map.zip, beginning with the .map file. This may allow for counting every other one, or perhaps it would be more efficient to exclude the .zip file extension. This is where I am hung. " See Input below* C:\>type zip2.bat Code: [Select]@echo off setLocal EnableDelayedExpansion echo. > ziplist.txt echo. > finalziplist.txt findstr /v "zip" list2.txt findstr /v "zip" list2.txt > ziplist.txt set /a c=0 for /f "delims=" %%a in (ziplist.txt) do ( set /a c+=1 set map!c!=%%a echo map!c! = %%a echo map!c! = %%a >> finalziplist.txt ) REM echo map!c! = !map1! OUTPUT: C:\>zip2.bat house1.map house2.map house3.map house4.map map1 = house1.map map2 = house2.map map3 = house3.map map4 = house4.map C:\>type finalziplist.txt map1 = house1.map map2 = house2.map map3 = house3.map map4 = house4.map C:\> *Input: C:\>type list2.txt house1.map house1.map.zip house2.map house2.map.zip house3.map house3.map.zip house4.map house4.map.zip C:\> |
|