Hi all. Have been a Gnome user since starting with Ubuntu back in the Feisty days. Have flirted with KDE here and there but never really given it a good enough crack of the whip. I'm afraid I'm not really keen on Unity. Gnome Shell requires too much effort to get it useable. XFCE isn't too bad, but it's a bit rough round the edges. It's time to give KDE another go.
My sticking point is Service Menus and the working directory. I've written an really simple script to rename files in preparation for publishing on the web.
It lower-cases everything and replaces spaces and underscores with a dash. IE "File_name with space.txt" would become "file-name-with-space.txt". It works perfectly in Gnome with Nautilus Scripts. KDE, however, is making me work!!!Code:#!/bin/bash for arg do converted_name=$(echo "$arg" | sed -e 's/ /-/g' | sed -e 's/_/-/g' | tr [A-Z] [a-z]) mv "$arg" "$converted_name" done
I've made a service menu for it...
...but it's not quite working properly. The "%U" on the exec line passes in the full path for each file. That's nice and comprehensive. However, my script won't work properly with that.Code:[Desktop Entry] Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=application/octet-stream Actions=renameForWeb [Desktop Action renameForWeb] Name=Rename For Web Exec=/home/me/scripts/rename-files.sh %U
For example, "/home/me/Pictures/File Name.jpg" will get converted to "/home/me/pictures/file-name.jpg". The "pictures" folder will also get lower-cased, causing the script to fail.
The other option is to use %N on the exec line which passes in just the file names, without the path. The problem with that, is that the working directory isn't where the files you've selected are (ie the ~/Pictures folder in this example). It seems to be using ~/scripts as the working directory.
I realise I could try and pass the working directory from the service menu to the script but that will mean re-writing the script and making it pretty complicated. Is there any way of changing the working directory in the service menu, before executing the script?
This is my "got to have" thing. If I can get this working, you've got a KDE convert on your hands!!
Bookmarks