How Do I Batch Convert Hundreds of ClarisWorks Documents to a Modern Format

clarisworksfile conversionsoftware-recommendation

I'm running the current version of Sierra (10.12.5). The documents appear in Finder without extensions and the system has given them exe icons despite categorizing them as Documents. They are unviewable with QuickLook and mdls identifies their type as CWWP.

LibreOffice is able to open the documents without all the weird crud and formatting issues that appear when opening them with other applications [Word/TextEdit/Atom/OpenOffice/Etc.]. And the "soffice –headless" commandline tool allows one to attack entire directories. Great. But I can't find an option to retain the original Date/Time Created stamps to the converted files.

I did find some freeware that will convert old WordPerfect docs to modern formats, but it doesn't work with my ClarisWorks docs.

I attempted to use the app DocumentConverter, but it crashes every time I try to export anything.

I've, also, attempted to use unoconv in conjunction with LibreOffice but have slammed against the brick wall of an unfixed bug from 2012.

Additionally, I found this bash script, which purports to do exactly what I need. However, in practice, the batch function doesn't work and the script has no setting to retain the original Date/Time stamps.

What I'm hoping to find is a simple commandline tool that I can aim at entire folders of these documents to convert in place, with the ability to retain the Date/Time Created stamps.

What are my best options?

Thanks.


08.05.17 – EDIT:

I'd like to thank @patrix for his bash script. It should come in very handy.

& I'd like to let anyone who has come across this while searching for a solution know that the developer of the libmwaw library (& associated tools) very nicely updated the source and his mwawOSX app to enable created date/time inheritance for converted ClarisWorks files.

Best Answer

Taking most of the relevant stuff from the bash script you've linked to and adding some commands to copy the timestamp from the original file to the newly created one will give you

#!/bin/bash

SOFFICE="/Applications/LibreOffice.app/Contents/MacOS/soffice"

[[ -x "$SOFFICE" ]] || exit 1
[[ -r "$1" ]] || exit 2

$SOFFICE --headless --convert-to docx:"MS Word 2007 XML" "$1"

ts=$(stat -f "%Sm" -t "%Y%m%d%H%M.%S" "$1")
docx=$(basename "$1" .cwk).docx
touch -t $ts "$docx"

This will convert one file (passed as an argument, including a path if applicable) from cwk into docx, store the docx in the current directory (which may be different from the place of the source file) and apply the "last modified" date from the original file to the converted one.