windows batch - update different files

Microsoft Windows xp professional w/serv...
June 10, 2010 at 05:53:49
Specs: Windows XP
I am trying to create batch file that would add some lines at the end of the file in one folder. Problem is that on every computer the file has different name (same extension.).
How do add add data into file with different name?
Thank you in advanced and best regards, M

See More: windows batch - update different files

Report •

June 10, 2010 at 08:13:55
Assume your Extension is "TXT" and your folder is "MY FOLDER" then just use a wild card.....

@echo off
for /f "tokens=*" %%a in ('dir "c:\my folder\*.txt" /b') do (
    echo The Line I want to insert >> %%a

With out more details like the Extension you are using or the Folder you are using, I can not make the code more exact.

Report •

June 10, 2010 at 09:24:31
yeah, you need some way to identify the file unless it's the only file with that given extension in the given directory.
You could poss. use the file's content (using findstr to locate
specific text that's consistant in the file) or naming convention
(such as %username% or %computer%) if that applies.
If you have more information about the file, that would help solve.

Report •

June 11, 2010 at 03:35:55
I would like to add a picture and html code into existing *.htm file which is used for signature in email application.
File is always Signture"Name of person".htm in folder c:\emailsignature\Signature"Name".htm
Following script just copies picture into folder but does not add following htm code into file:
@echo off
copy environment.gif c:\emailsignature\
for /f "tokens=*" %%a in ('dir "c:\emailsignature\*.htm" /b') do (
echo "
img width=142 height=23  src="environment.gif">"
 >> %%a

Report •

Related Solutions

June 11, 2010 at 18:21:39
maybe (after the gif copy):
for %%a in (c:\emailsignature\signature*.htm) do copy %%a + sig.htm %%a
::------- end
put sig.htm into the same directory where the .gif file originates from.
sig.htm content is just your:

depending on the situation, you might need to test to see if
the sig has already been appended:
find /i %%a "environment.gif" || copy %%a + sig.htm ...

ps: this could also work, but I prefer the aforementioned method:
(fixing the code you were using, not tested):
for /f "tokens=*" %%a in ('dir "c:\emailsignature\*.htm" /b') do (
>> %%a echo ^

Report •

Ask Question