DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: DONE: Paste Something To Bottom Of All Text Files, Recursively  (Read 8,355 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 563
Wondering if anyone knows of a present way, or perhaps it can be made.

I have a folder of text files, each in their own subfolders, and I want to place the following at the very bottom of each of the text files:

endsas;

Not necessary, but nice to put a blank line above, separating from rest of text.

Thanks much, folks.

Nicholas Kormanik

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: DONE: Paste Something To Bottom Of All Text Files, Recursively
« Reply #1 on: February 15, 2013, 09:40 AM »
Most likely you can fix that using (DC-member) stahlworks Swiss File Knife
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: DONE: Paste Something To Bottom Of All Text Files, Recursively
« Reply #2 on: February 15, 2013, 12:11 PM »
Put this in a DOS batch file and then at a prompt type: RecAppTxt.cmd <path>

Where <path> is the top level directory you want, eg. RecAppTxt.cmd D:\TXT_Files_Below_Here\Demo

Don't forget to put <path> in quotes if it has spaces.

Code: (generic)
REM RecAppTxt.cmd
for /r %1 %%f in (*.txt) do (echo. >>%%f && echo "endsas;" >>%%f)

Try it on a test directory first, it worked here but who knows
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 563
Re: DONE: Paste Something To Bottom Of All Text Files, Recursively
« Reply #3 on: February 15, 2013, 11:50 PM »
Thanks 4wd.  Excellent approach.

Ath, while Swiss File Knife does a lot, I don't think it can do what's being asked.  But thanks for your suggestion.

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: DONE: Paste Something To Bottom Of All Text Files, Recursively
« Reply #4 on: February 15, 2013, 11:59 PM »
You can also split it into a two line batch/command file, just in case the resultant echo command results in a really long command line, (long path/file names).

eg.

Code: (generic)
for /r %1 %%f in (*.txt) do (echo. >>%%f)
for /r %1 %%f in (*.txt) do (echo "endsas;" >>%%f)

It'll add the blank line on the first and the the "endsas;" on the second.
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 563
Re: DONE: Paste Something To Bottom Of All Text Files, Recursively
« Reply #5 on: February 16, 2013, 12:06 AM »
Terrific, 4wd.

Hope this helps others as well.

Skwire, unless someone has more to add, another DONE.

Original address: https://www.donationcoder.com/forum/index.php?topic=34043.0