0

I'm using Dolphin in a KDE Plasma 5 Desktop Environment. Here I wrote a bash script, which can elaborate exactly ONE file, when I drag a file from Dolphin and drop it on a ".desktop" defined script with an icon, which then executes e.g. /home/user/scripts/list_all_drags.sh %f.

This works with such one file. Now I would like to drag several selected files from Dolphin into the script and the script should elaborate its procedures for each file entry. This doesn't work, though I used %F for multiple files instead of %f for a single file.

What happens is, that several terminal windows are opened, one for each file entry. What I need is the code to be executed in ONE script, for each file entry dropped, without opening several terminal windows, but the first one. Exactly, the "loop" to start or to execute the commands with the dropped files, without any more key press.

I don't know how to handle the %F parameter value in my script.

  • Works for me as advertized, I get the separate scripts only if I replace %F with %f. How do you create the .desktop? – xenoid Jun 1 '17 at 19:37
  • When you right click on menu symbol left side down, then chose "edit applications" (first entry), then you'll see the KDE menu structure. Here you can select a group and within the group you can then select "New element" from menu bar. This is already a ".desktop" base file, which you can adopt for your needs. – Linuxwhisperer Jun 2 '17 at 8:59
  • ... name it, chose an icon and select the program or script, you want to execute, then you'll need to "Save" (Left item in menu bar) to create this new ".desktop" file, which is named as you have named it. This file is saved at: /home/user/.local/share/plasma_icons – Linuxwhisperer Jun 2 '17 at 9:14
  • Yes, I know, but this doesn't create an icon on the desktop... So where do you drag your files? Also, if you select several files in Dolphin, right click, Open with... and select your app, do they get all processed together or do they still get a script instance each? – xenoid Jun 2 '17 at 13:06
  • When you finished the new element with "Save", then you can find it by typing the name, when you launch KDE (Plasma) menu. Then you can drag and drop the new item (icon) onto your desktop or into a task line. – Linuxwhisperer Jun 2 '17 at 18:54
0

I think, I've found the correct answer, especially how to handle the multiple parameters with %F.

First I select my entries (files) in a filemanager. Second I drag all these marked files onto my script icon and drop them on that icon. Inside this script which is executed with "/home/user/scripts/myscript.sh %F" there is a routine, which elaborates all selected file entries.

Though I'm not sure how many parameters (files) could be mass selected and elaborated then, this routine here helps me to count up all single parameters greater than 0 (which are my selected, my marked files):

while (( $# > 0 )) # or [ $# -gt 0 ] do echo "$1" shift done

Instead of "echo $1" I can say

file = $1

and then call my subroutine where I work with $file

Special thanks to this post: How to handle more than 10 parameters in a shell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.