I'm sure a suitable Google would help me here but I'm not sure what to search for; a few random attempts got me close but not close enough.
I have to work a lot with XLS files which need converting to CSV files (using a tab separator). At the moment I do this using OOo which is overkill.
I could do this from the commandline using htmldoc/xls2csv but that's not all that convenient in the GUI environment either.
So what I would like to do is right-click the file in Nautilus and click a "convert to TSV" menu option that I set up to use xls2csv, taking blah.xls to create blah.csv.
Where do I start?
There's lots of similar stuff I'm used to from Windows (eg using the context menu to create/extract zip/etc files) although I wouldn't know how to do it on Windows either - I'd rely on the relevant apps setting that up for me.
Hi,
2008/12/17 Mark Rogers mark@quarella.co.uk:
So what I would like to do is right-click the file in Nautilus and click a "convert to TSV" menu option that I set up to use xls2csv, taking blah.xls to create blah.csv.
Where do I start?
There might be something similar to what you want in the Nautilus scripts section:
http://www.gnome-look.org/index.php?xcontentmode=188
Or at least something you could use as a template to help you make your own script.
Srdjan
Mark Rogers wrote:
I'm sure a suitable Google would help me here but I'm not sure what to search for; a few random attempts got me close but not close enough.
I have to work a lot with XLS files which need converting to CSV files (using a tab separator). At the moment I do this using OOo which is overkill.
I could do this from the commandline using htmldoc/xls2csv but that's not all that convenient in the GUI environment either.
So what I would like to do is right-click the file in Nautilus and click a "convert to TSV" menu option that I set up to use xls2csv, taking blah.xls to create blah.csv.
Where do I start?
There's lots of similar stuff I'm used to from Windows (eg using the context menu to create/extract zip/etc files) although I wouldn't know how to do it on Windows either - I'd rely on the relevant apps setting that up for me.
http://www.gnome-look.org/content/show.php/Audio%2BVideo%2BImage%2BText+Conv...
Could work, have not tested it personally though.
Srdjan Todorovic wrote:
There might be something similar to what you want in the Nautilus scripts section:
Thanks for this. There are some similar scripts (like the avconvert one mentioned elsewhere) and I'm trying to work out enough of how they work to make them do what I want.
The problem I'm having is that these scripts are fairly evolved so quite clever but not very easy to follow as a first step. But using phrases I learnt from this thread (like the fact that I'm interested in "nautilus scripts") has lead me to: http://g-scripts.sourceforge.net/faq.php and http://ubuntuforums.org/showthread.php?t=768892 .. which are more "How-To"-ish.
Interesting that .doc to .html/.txt/etc seems to be quite a common requirement but .xls to .csv/.ods is "missing". I must have "special needs"!
Maybe I'm missing something (I'm a primarily a KDE user), but last time I had to do something like this, I just created a simple shell script which was named after what I wanted to see in the Gnome context menu:
~/.gnome2/nautilus-scripts/Convert\ XLS\ to\ CSV...
with the contents performing the action I required, so something like:
#!/bin/bash # Convert XLS files to CSV... notrailspace=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/^ *//' -e 's/ *$//') sh /usr/bin/xls2csv "$notrailspace"
should do what you want (not tested tho). I needed the extra sed gubbings for the command I was calling, but you might get away with removing it, depending on how xls2csv works. Don't forget to make it executable.
The above isn't perfect, as I don't think it will differentiate what files you have selected and then only show when you right-click on XLS files, which might be possibly if you read around.
Peter.
samwise wrote:
with the contents performing the action I required, so something like:
#!/bin/bash # Convert XLS files to CSV... notrailspace=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/^ *//' -e 's/ *$//') sh /usr/bin/xls2csv "$notrailspace"
Thanks for the help so far, this looks like a good opportunity to learn something new. I was determined to make 2008 the year of learning new stuff and I'm leaving it a bit late to get started!
Based on the above (and very little bash script skills!) I tried: #!/bin/bash # Convert XLS files to CSV... files=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/^ ?(.*)(.xls) ?/"\1\2" > "\1.csv"/i') xls2csv $files
.. which I wanted to take /path/to/foo.xls and run xls2csv /path/to/foo.xls > /path/to/bar.csv
It doesn't work (no surprised on a first test like this) but I have absolutely no idea how to debug it? Where would errors go?
On Fri, 2008-12-19 at 09:01 +0000, Mark Rogers wrote:
Based on the above (and very little bash script skills!) I tried: #!/bin/bash # Convert XLS files to CSV... files=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -e 's/^ ?(.*)(.xls) ?/"\1\2" > "\1.csv"/i') xls2csv $files
.. which I wanted to take /path/to/foo.xls and run xls2csv /path/to/foo.xls > /path/to/bar.csv
It doesn't work (no surprised on a first test like this) but I have absolutely no idea how to debug it? Where would errors go?
To debug it the best way initially would be to run it from the shell with NAUTILUS_SCRIPT_SELECTED_FILE_PATHS hard set to a test file at the begining of the script.