| 1. |
Solve : batch function - need to add filename at the end of each paragraph? |
|
Answer» Hi, I have a bunch of text files I need to add the filename at the end of each paragraph to. There's a lot of paragraphs in each file. Ideally it would have a dash, space, then the filename (without extension) so it would LOOK something LIKE this: line with text - filename The Office suite of applications has a rich set of features. There are many different ways to author, format, and manipulate documents, email, databases, forms, spreadsheets, and presentations. The great power of VBA programming in Office is that nearly every operation that you can perform with a mouse, keyboard, or a dialog box can also be done by using VBA. Further, if it can be done once with VBA, it can be done just as easily a hundred times. (In fact, the automation of repetitive tasks is one of the most common uses of VBA in Office.) It may take yu some time to learn it, but after that you can do things much faster and better that using batch programs. VBA is also found in Office Suites from other software companies. It is the de facto standard for programming in Office STUFF. Or, yu could learn Python. Of course, you can do it in DOS batch. If you wish, somebody will be here shortly to help you. But be prepared to make a very clear definition of your task.We need more details of the "text file" format. Is each line terminated with an LF or CR+LF, or is each "paragraph" one long (wrapped) line? Is the marker for end-of-paragraph a blank line? Quote I need to add the filename at the end of each paragraphQuote it would look something like this: line with text - filename Do you mean you want the text appended to the last line of each paragraph, like this? Here is the input plain text (called HGWells.txt) Filby became pensive. "Clearly," the Time Traveller proceeded, "any real body must have extension in _four_ directions: it must have Length, Breadth, Thickness, and - Duration. But through a natural infirmity of the flesh, which I will explain to you in a moment, we incline to overlook this fact. There are really four dimensions, three which we call the three planes of Space, and a fourth, Time. There is, however, a tendency to draw an unreal distinction between the former three dimensions and the latter, because it happens that our consciousness moves intermittently in one direction along the latter from the beginning to the end of our lives." "That," said a very young man, making spasmodic efforts to relight his cigar over the lamp; "that . . . very clear indeed." "Now, it is very remarkable that this is so extensively overlooked," continued the Time Traveller, with a slight accession of cheerfulness. "Really this is what is meant by the Fourth Dimension, though some people who talk about the Fourth Dimension do not know they mean it. It is only another way of looking at Time. _There is no difference between Time and any of the three dimensions of Space except that our consciousness moves along it_. But some foolish people have got hold of the wrong side of that idea. You have all heard what they have to say about this Fourth Dimension?" Do you want the output text to be like this? Filby became pensive. "Clearly," the Time Traveller proceeded, "any real body must have extension in _four_ directions: it must have Length, Breadth, Thickness, and - Duration. But through a natural infirmity of the flesh, which I will explain to you in a moment, we incline to overlook this fact. There are really four dimensions, three which we call the three planes of Space, and a fourth, Time. There is, however, a tendency to draw an unreal distinction between the former three dimensions and the latter, because it happens that our consciousness moves intermittently in one direction along the latter from the beginning to the end of our lives." - HGWells "That," said a very young man, making spasmodic efforts to relight his cigar over the lamp; "that . . . very clear indeed." - HGWells "Now, it is very remarkable that this is so extensively overlooked," continued the Time Traveller, with a slight accession of cheerfulness. "Really this is what is meant by the Fourth Dimension, though some people who talk about the Fourth Dimension do not know they mean it. It is only another way of looking at Time. _There is no difference between Time and any of the three dimensions of Space except that our consciousness moves along it_. But some foolish people have got hold of the wrong side of that idea. You have all heard what they have to say about this Fourth Dimension?" - HGWells Yes, let me give you examples. The text currently looks like this: Website 1 - www.website1.com Website 2 - www.website2.com Website 3 - www.website3.com I would like it to look like this: Website 1 - www.website1.com - filename 1 Website 2 - www.website2.com - filename 2 Website 3 - www.website3.com - filename 3 (without the extension if possible, but if that's not possible I can live with the extension) They are regular paragraphs with regular paragraph markings. There's only 1 regular line in-between each one. Nothing fancy at all. Thank you!!! Those are not paragraphs; they are lines. |
|