Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to modify this for loop:  (Read 7745 times)

0 Members and 1 Guest are viewing this topic.

billrich

  • Guest
Re: How to modify this for loop:
« Reply #15 on: October 16, 2009, 02:37:02 PM »

I want to ONLY list the .map files as a map and skip the .map.zip
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.



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:\>



PPowerHouseK

  • Guest
Re: How to modify this for loop:
« Reply #16 on: October 16, 2009, 04:18:42 PM »
Well it now works perfectly. Thanks guys that did just the trick.  ;D
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. 8)

billrich

  • Guest
Re: How to modify this for loop:
« Reply #17 on: October 16, 2009, 05:13:54 PM »
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:\>
« Last Edit: October 16, 2009, 05:34:54 PM by billrich »