need help with batch file to edit two text files
Moderator: DosItHelp
Re: need help with batch file to edit two text files
thank you so much for your help
Re: need help with batch file to edit two text files
hi again, i have another problem. since this is a similar problem i thought i would post it under this topic.
i need a batch file that can combine the text in two different txt files into one. for example
name.txt
tony
josh
tom
Size.txt
Large
Small
and then combine the text into:
total.txt
tony Large
Josh Small
tom
as shown not all text will have something to combine with but it will still need to be copied over to the total.txt.
also if possible i would like there to be a space between each combine however no space to appear after non combined text or after combined text (if that is not possible that will be fine as long as there are no spaces anywhere but for the ones that ware originally in the text (such as 'tony smith' or 'very large')
any help would be greatly appreciated!
kind regards
Josh
i need a batch file that can combine the text in two different txt files into one. for example
name.txt
tony
josh
tom
Size.txt
Large
Small
and then combine the text into:
total.txt
tony Large
Josh Small
tom
as shown not all text will have something to combine with but it will still need to be copied over to the total.txt.
also if possible i would like there to be a space between each combine however no space to appear after non combined text or after combined text (if that is not possible that will be fine as long as there are no spaces anywhere but for the ones that ware originally in the text (such as 'tony smith' or 'very large')
any help would be greatly appreciated!
kind regards
Josh
Re: need help with batch file to edit two text files
You should show more examples from your text files.
Re: need help with batch file to edit two text files
This will do as the OP asked - he can get back to us with more info if it fails.
! characters will cause an issue.
! characters will cause an issue.
Code: Select all
@echo off
setlocal enabledelayedexpansion
<Size.txt (
for /f "delims=" %%a in (name.txt) do (
set "var="
set /p "var="
if defined var set "var= !var!"
>>total.txt echo %%a!var!
)
)
Re: need help with batch file to edit two text files
that works great thanks foxidrive!
sorry Endoro, in future ill show more examples
sorry Endoro, in future ill show more examples