batch for txt file editing

October 15, 2011 at 09:38:20
Specs: Windows 7
hi im the noobiest guy but ive been told to try toms guide web site

i need a batch file (i think?) to edit a lot of lines in a txt file

the txt full of lines like this

0526a3f6b73183229b5690c7f010d45e:assets/buildings/new_gunshop_mastery_1_icon.png

i need to add "http://mw2.static.zgncdn.com/hashed/" before the line
and i also need to remove whatever comes after ":assets" but to keep the .png

so again from

0526a3f6b73183229b5690c7f010d45e:assets/buildings/new_gunshop_mastery_1_icon.png
to
http://mw2.static.zgncdn.com/hashed...

thanks in advanced.


See More: batch for txt file editing

Report •

#1
October 15, 2011 at 14:20:18
Confused again. i also need to remove whatever comes after ":assets" but to keep the .png

Does the details you posted not show that :assets has been removed, not just what comes after :assets? So should the output read

.......f010d45e:assets.png
or
.......f010d45e.png 

Below are two scripts, the first leaves :assets in the output, the second removes it. Take your pick:

Script 1

@echo off
cls
setlocal enabledelayedexpansion

set add=http://mw2.static.zgncdn.com/hashed/
set extn=.png

for /f "tokens=1* delims=/" %%1 in (infile.txt) do (

        echo !add!%%1!extn!>>outfile.txt
)

Script 2

@echo off
cls
setlocal enabledelayedexpansion

set add=http://mw2.static.zgncdn.com/hashed/
set extn=.png

for /f "tokens=1* delims=:" %%1 in (infile.txt) do (

        echo !add!%%1!extn!>>outfile.txt
)


Please come back & tell us if your problem is resolved.


Report •
Related Solutions


Ask Question