Python - Moving entire text between two .doc files -


I am having this problem for a while and can not understand how I should start doing this with Python? My OS is Windows XP Pro. I need a script which takes the whole (100% lesson) text from one .doc file to another. But this is not as easy as the target .doc file is not just one, but many of them may be. All target .doc files are always in the same folder (similar paths), but not all of them have the same name .doc file from which I want to move the whole text is only one, always in the same folder (The same path) and always with the same file name. The names of the goal are the same, but as I said earlier, not the same. Here's the full script: the names of the target.doc files are:

HD1.doc HD2.doc HD3.doc HD4.doc

and so on On

The whole text in the .doc file with the highest (!) Number (but all text in fact, 100% must be all) I want to do. The target .doc files always start with "HD" and are always similar to the above examples. It is possible that the doctor file (the target file) is only one, so only HD1.doc is therefore '' 1 '' maximum number and the text has been moved to this file. Sometimes the goal file is empty but will not usually be, if it does not, the text should be moved at the end of the text, in the first new row (no empty lines inbetween). For example, the maximum number of its name in the target file is the following:

A

b

c

In that file I want to transfer the text from:

d

This means that I need it in the target file:

a

B

C

D

But there are no empty lines anywhere.

I have found (showing three different codes):

But none of them has any meaning for me. I know that I need to start with the correct target file (the correct HDX file where x is the highest number - then all the files will be in the same folder and will be in the same folder), but this is not how it is known.

I mean the Microsoft Office Word Doc file. They have "pure text" what I mean by pure text that Im also able to see them in Notepad (.txt). But I have to work with the .doc extension. I is a Python because I need this automated system, so I do not have to open any file. Why not exsactly Python and any other programming language? The reason for this is that recently I started learning dragon and my work requires this script - Python is the "only" programming language that I am interested in and that's because I want to do this script with it . Through "really 100%" I will be taken into the entire file (everything in the source file - every single line, no matter if 2 or many thousands) is correct (which is a right that is mentioned in my first post) . I can not take the entire file because I have the entire text (everything gathered - the source file will always be the same but the competition of the text will always be different - in different words) and should not take the entire file because I need the correct text Document file with the correct file and together ("simultaneously" I mean in the same file) already with existing text if the target file already has something i It is possible that the correct target file is also empty.

If someone can give me some ideas, then I appreciate it.

Thanks, good luck.

I have tried to ask at the OpenOffice forum but they do not answer. Code can be something like this:

  Import sleep imports from time to win32com.client from win32com.client import dispatch wordApp = win32com.client.Dispatch ('Word.Application') wordApp.Visible = false WordApp.Documents.Open ('C: \\ test.doc') sleep (5) HD1 = Word app. Document. Open ('C: \\ test.doc') # HD as Word document object. HD 1. Communication Choose. Copy () # Select the entire document and copy it ` 

but I do not know what it means. Also, I can not use the .doc file because I never know that the correct file name (HDX.Doc where X is the maximum integer number, all HD are in the same directory path) and therefore I do not use its name Could the script find the correct file, besides '' filename '' = word application.documents.open ... will definitely give me a syntax error: - (

Poo Open Office ship with full Python scripting support, take a look:

Trying to mess with MS Word and Com API can be easy.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -