Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to make a batch file that inserts a string at the beginning of every line of a text document and at the end of a line. eg.
(String Here)test123456(String Here2)
(String Here)test(String Here2)
(String Here)1234test(string Here2)ect.

@echo off > newfile & setLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%a in (myfile) do (
echo STRING %%a STRING >> newfile
)
=====================================
If at first you don't succeed, you're about average.M2

Thanks, that is exactly what i wanted. :D
Another thing, how do i delete the strings only at the end of the linetest123456(Delete String)
9784654613054086(Delete String)ect.

Do you mean a particular string? Or whatever the last string happens to be? Big difference.
=====================================
If at first you don't succeed, you're about average.M2

ummm, i need to remove the " at the end of every line in a text document (instead of deleting them all 1 by 1)
eg.text"
text1"
text10"
text50"ect.
Might be something like this, but it only deletes the characters from the start of the row.
|
˅SetLocal EnableDelayedExpansion
for /f "tokens=1*" %%a in (text1.txt) do (
set Row=%%a %%b
set Row=!Row:~1!
echo.!Row!>> text2.txt
)

@echo off > newfile & setLocal EnableDelayedExpansion
for /f "tokens=*" %%a in (myfile) do (
set Row=%%a
set LC=!Row:~-1!
set DQ="
if !LC!==!DQ! (
set Row=!Row:~0,-1!
)
echo.!Row!>> newfile
)
=====================================
If at first you don't succeed, you're about average.M2

lol, sorry i have another issue,
@echo off > List2.txt & setLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%a in (List.txt) do (
echo "for /f "delims=*" %%i in ('dir /b /s "*%%a*"') do del /p /s "%%i"">> List2.txt
)%%a is the text in the list.txt
eg.
song1.mp3
song2.mp3
song3.mp3I have an issue where it: (list2.txt)
"for /f "delims=*" %i in ('dir /b /s "*song1.m3.mp3*"') do del /p /s "%i""
"for /f "delims=*" %i in ('dir /b /s "*song2.m3.mp3*"') do del /p /s "%i""ect.
where the %i is, it is missing another % should be %%i
I don't know why it does that...
Any help?

I don't know what you're trying to accomplish but you probably need to add an extra %
=====================================
If at first you don't succeed, you're about average.M2

This might help:
http://img9.imageshack.us/img9/7346...
Song_list2.txt will be a batch file by the way

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |