Writing, publishing, geekdom, and errata.

Pass OSX and Linux File Paths to Windows Programs Running Under WINE In One Script

No comments

tl;dr: Even with WINE to let you run Windows software in Linux or OSX, the filenames are formatted differently. This shell script fixes that so you can set it as an file association in Finder, Nautilus, Dolphin, etc.

technology.pngWhen you're using linux or OS X, there are just some times that you want (or have) to use a Windows program.  There's a free program/layer/whatever called WINE that lets you do just that (Linux downloads here, OSX folks, look here) for most Windows programs (here's a database of working programs).

A good example for me is the awesome Windows freeware graphics viewer and editor IrfanView.  (While I use IrfanView as an example, this same principle would work for other filetypes, such as MS Office files.)

It's not my viewer of choice (that's Viewinor) or my heavy-duty editor of choice (the unfortunately-named GIMP), but IrfanView works great for middle-level image manipulation with a simple GUI.1

I'm defining middle-level manipulation as things like:
  • Batch resizing
  • Batch format conversion
  • Quick visual cropping
These sorts of things are awesomely easy, intuitive, and fast with IrfanView - even under WINE - because it's such a lightweight program.  When I'm just needing to crop a single photo with a quick mouse-dragged rectangle, I don't want to wait.

But there's a problem.  Windows expects file names to be formatted like this:


but both linux and OSX expect


Which means that even if I set up a file association in my viewer (OSX, Ubuntu, KDE), I'll have to manually choose the file. Which takes time, and kind of defeats the purpose.  So I made a quick BASH script to automagically change the path format from *nix/OSX to Windows and run the program through WINE.   It's currently written for a default IrfanView installation in a default WINE installation (IIRC);  you'll have to edit it slightly for the home directory location anyhow.

Then you can make the script executable and make it the default (or optional) association for image filetypes. It's a little work to set up once, but if there's a Windows program you have to or want to use frequently, this will save you a lot of work in the long run.

1 Yes, ImageMagick is hugely powerful, but I don't need that level of control - and if I did, I'd be using GIMP for it.

No comments :