0

I have a large folder of word 2003 files (200+). I need a way to make sure that every file ends with the exact same characters. Some of these files already end with this characters so I cannot duplicate the ending.

What I need is that every file, after it's last character, usually a "." but not always, I need to have two carriage returns, and nothing else. Emphasis is here is the 2 returns, no more than that.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Fortinbra
0

The way I would do it is to create a vbscript file that creates a Microsoft Word object and uses that in a loop to open each file in the folder and check the text. If you are not familiar with scripting or creating scripted controls then it becomes very difficult. I had to create many such scripts to tie processes together before I retired.

0

Yes I do, quite a bit actually. I managed to solve my own issue by creating a C# winforms app that used the Microsoft.Office.Interop.Word namespace. I simply looped through all the text backwards till I found a character that wasn't a space or a new line. Deleted everything after that point, the added the correct number of new line characters at the end. As far as looping through the file system, LINQ made that easy to sort out only the .doc files.

Side note, I think I had a seizure watching Word flash across my screen that quickly.
7 min total for 768 files.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.