Results 1 to 2 of 2
-
22nd Jan 2011, 07:42 AM #1OPBanned
batch insert texts to the beginning of multiple files
How do I insert multiple texts to multiple files at once using a batch script?
The scenario:
I have 900 empty text files named "001.txt", "002.txt", "003.txt"..."900.txt". I would like to insert the html codes "<p>Number 001</p>", "<p>Number 002</p>", "<p>Number 003</p>"..."<p>Number 900</p>" to the beginning of each of these files. In other words i would like to insert the text "<p>Number 001</p>" to the file 001.txt, the text "<p>Number 002</p>" to the file 002.txt, etc. up to 900.
How do I do this using a batch script in windows?techdaemon Reviewed by techdaemon on . batch insert texts to the beginning of multiple files How do I insert multiple texts to multiple files at once using a batch script? The scenario: I have 900 empty text files named "001.txt", "002.txt", "003.txt"..."900.txt". I would like to insert the html codes "<p>Number 001</p>", "<p>Number 002</p>", "<p>Number 003</p>"..."<p>Number 900</p>" to the beginning of each of these files. In other words i would like to insert the text "<p>Number 001</p>" to the file 001.txt, the text "<p>Number 002</p>" to the file 002.txt, etc. up to 900. Rating: 5
-
22nd Jan 2011, 08:02 PM #2Respected Member
Here you go. Create a file called run.cmd or run.bat in the folder with the *.txt files and execute it in the cmd window.
Code:@echo off & setLocal EnableDelayedExpansion for /f %%R in ('dir /b *.txt') do call :1 %%R goto :eof :1 set var=%1% echo "<p>Number %var:~0,-4%</p>" >> %var%
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
How to batch rar indiviual files?
By Ruriko in forum Webmaster ResourcesReplies: 0Last Post: 6th Dec 2011, 12:49 AM -
Rar Multiple Avi Files At Once, How To?
By TexWilliams in forum Webmaster DiscussionReplies: 4Last Post: 4th Jul 2011, 11:09 AM -
Which is the best site for batch upload files to multiple host?
By elpirata in forum Webmaster ResourcesReplies: 6Last Post: 25th Feb 2011, 02:56 PM -
replace multiple different texts in different text files
By techdaemon in forum Technical Help Desk SupportReplies: 13Last Post: 20th Jan 2011, 04:54 PM -
Renaming Multiple Files in SSH
By Crucify in forum Technical Help Desk SupportReplies: 6Last Post: 29th Jun 2009, 04:37 PM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...