Computing.Net > Forums > Programming > batch file help

batch file help

Reply to Message Icon

Original Message
Name: elfudge35
Date: March 2, 2006 at 09:05:50 Pacific
Subject: batch file help
OS: XP
CPU/Ram: Pentium 4, 512 mb
Model/Manufacturer: IBM ThindPad
Comment:

I need to create a batch file to insert the file name into the first line of approximately 700,000 text files, can anybody help?


Report Offensive Message For Removal


Response Number 1
Name: shahramsh
Date: March 2, 2006 at 16:41:45 Pacific
Subject: batch file help
Reply: (edit)

if you don't care about a "" sign at the end, this might help

====================
@echo off
md done
copy mtext.txt+%1 done\%1
====================

where mtext.txt is:
====================
Your Text

====================

or you could use a "for" command to append it line by line, but I wouldn't use it for my sensitive texts


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: March 2, 2006 at 23:07:56 Pacific
Subject: batch file help
Reply: (edit)

Try this:

::== nameinto.bat
@echo off

for %%T in (*.txt) do call :sub1 %%T
goto :eof

:sub1

echo %1>#
copy /b #+%1 ## > nul
del %1
ren ## %1
goto :eof
:: DONE


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: batch file help

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge