1

I want to use nautilus actions with my own script which I have usually started successfully with open-terminal and pasting the command (s. below) directly in the terminal.

for file in *.mp4; do mkdir "${file%.mp4}"; mv "${file}" ./"${file%.mp4}"; done

Using nautilus config tool now, I do not know how to insert the command in the dedicated field (see picture 1) or how to write an adequate bash script file (see picture 2). Can someone give a hint?

Picture 1: attempt to load script (below) over .gnome2/nautilus-scripts enter image description here

Picture 2: attempt to write a script enter image description here

2
  • You're splitting the mv command over 2 lines: don't do that. Sep 12, 2014 at 13:17
  • Ah, this was just a avoidable copy 'n' paste mistake. Thank you, Glenn! But it gives me the following error message (in spanish): mv: no se puede efectuar `stat' sobre «*.mp4»: No existe el fichero o el directorio
    – Til Hund
    Sep 12, 2014 at 20:19

2 Answers 2

0

You're in a directory with no mp4 files. When a glob pattern (like *.mp4) does not match any files, the pattern is treated as a literal string ("*.mp4")

In bash you do this to replace a pattern that matches no files with the empty string:

shopt -s nullglob

So, it seems that your script is not running in the directory you think it should be running in. You might want to add a echo $PWD line to debug.

2
  • Thank you very much, Glenn, that you take your time to answer to me! But I am not quite sure if I can follow: Why would the command in question function when I use it by copy 'n' pasting it into a terminal which I led via cd to the directory with the mp4 inside, but would not when I use the bash script above which I have used in the same directory with the mp4 file inside?
    – Til Hund
    Sep 13, 2014 at 14:48
  • When nautilus runs it, how sure are you what directory the script is running in? Do you think you know, or are you sure you know? Sep 13, 2014 at 22:05
0

Problem solved with cd $(dirname $(readlink -f $0)), see link here. :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .