Tips & Tricks, Tutorials, Hacking, Troubleshooting,

A few days ago, we posted an article detailing how to batch convert Microsoft Office formatted documents (doc, xls, ppt), to their Open Document counterparts (odt, ods, odp), using the built-in document converter found in LibreOffice. For many people, this will be a perfect method, as LibreOffice is already installed on their computers (particularly true for many Linux users).
For others, however, this isn’t the greatest solution, as LibreOffice is a very large program, that once installed can take up over 400 MB of space. Linux users have another option, although not as comprehensive, in the form of Abiword. Abiword is an open source word processor, available for Mac, Windows and Linux, and it can be used – from the Terminal, no less – to batch convert word processing documents.
Here’s how it works. First, if it’s not already installed, you’ll need to install Abiword. In Ubuntu, you can type sudo apt-get install abiword into a Terminal to install it.
Install Abiword In The Terminal
You can also use the Ubuntu Software Center. Just search for ‘abiword’ and install it that way.
Install Via Software Center
Once installed, you’ll find Abiword in the Dash.
Abiword In Dash
For our purposes, however, we won’t be opening Abiword, as the conversion can take place without any GUI, in the Terminal. So go ahead and open the Terminal.
Open Terminal
Now use the ‘cd’ command to change your working directory to where you keep your files that you want to convert. In our case we’ll type cd Documents/ as we store them in our Documents folder. Your command will vary depending on where your documents are.
CD To Documents Folder
If you have just a single file – let’s say it’s named Addresses.doc, then you can convert it to a different format (we’ll use Abiword’s native .abw for our purposes, but know that there are more than 2 dozen supported formats available) by typing abiword –to=ext document.ext into the Terminal, changing the appropriate pieces of information to match your document, of course.
Convert A Single Document
In our case, we changed “–to=ext” to “–to=abw” to tell Abiword to convert our document to the Abiword format, and “document.ext” to “Addresses.doc” to tell it which document to convert.
But this article’s title talks about batch converting documents. How do we do that? Simple. We wrap the above command in a bit of code, so that the conversion is run again and again, on every document that matches. For instance, let’s say we want o convert all documents of a particular type to .odt (Open Document Text). We would type for file in *.doc ; do abiword –to=odt “$file” ; done into the Terminal.
Batch Convert By File Type
This command tells Abiword that for every file that matches the string “.doc” to convert it to “.odt” and to use the document’s orginal name, replacing only the extension.
If you want to convert all documents in a folder (and they are all formats that Abiword can import), then you can replace “*.doc” in the above command with simply an asterisk, which would run the conversion on ALL documents. That command would look like this:
Batch Convert All Files
So if you used to have a folder full of MS Word documents, like this:
Folder of MS Word Documents
Simply run the command, and before you know it, you should have a folder with double the documents, your originals and the converted ones.
Folder with Originals and Converted Docs
At the end of the day, you still need to install a piece of software to get this to work. Now, Abiword is a lot smaller in size than LibreOffice, but of course it can’t convert nearly as many file types (only word processing documents, compared to word processing, spreadsheets, presentations and more). Still, if your needs are more aligned with converting word processing documents, this is a neat trick.

No comments:

Post a Comment