Computing.Net > Forums > Programming > add or replace text in .txt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

add or replace text in .txt file

Reply to Message Icon

Name: Saiuns
Date: March 6, 2009 at 01:04:56 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Hello,

I want to generate a text-file that lists all folder and subfolders as:
c:\foldername1\subfolder1\
and I want to proceed eacht folder line with a string:
sting c:\foldername1\subfolder1\
sting c:\foldername2\subfolder2\
etc...
and save the file as myfile.abc

I already have this:
dir /s /on /b /a:d > c:\myfile.abc
that gives me a list with the directorys. And I can use the command on a folder by RMB --> files listing

Now I want to add the string in front of each line. But I can't figure out how to add the string, I thougth maybe by replacing the "c:\" with "string c:\"?

I'm a real noob in .bat files and really appreciate your help

grtz



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: March 6, 2009 at 01:49:00 Pacific
Reply:

for /f "tokens=*" %%a in ('dir /s /on /b /a:d') do echo String %%a >>c:\myfile.abc

--
Holla.


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: add or replace text in .txt file

Find and Replace text in Batch File www.computing.net/answers/programming/find-and-replace-text-in-batch-file/12413.html

Replacing text in files BAT file www.computing.net/answers/programming/replacing-text-in-files-bat-file/16818.html

del text in txt file except dir www.computing.net/answers/programming/del-text-in-txt-file-except-dir/17223.html