Alfcx / linux-mint-nemo-actions

Some useful Nemo Actions and Shell Scripts with zenity GUIs: 1. Sandwich PDF Maker (OCR, Text Layer, searchable pdf, tesseract, scantailor); 2. PDF Page Rotator; 3. PDF Metadata Editor; 4. PDF Document Downsizer; 5. doc(x), odt, txt to pdf Converter; 6. doc(x) to odt Converter
29 stars 8 forks source link

pdf-merger can handle filenames with spaces? #1

Open kiers opened 10 years ago

kiers commented 10 years ago

I believe this script not handle spaces in names, correct? Any work around possible to handle filenames\ with\ spaces?

Alfcx commented 10 years ago

That is/was correct. Today's Release should have fixed the issue. Let me know if it works for you.

kiers commented 10 years ago

Hi Alfcx, afraid not (note: I commented out the config.ini and language selection portions of the shell file)

I've been tinkering with all manner of flag settings in Nemo Actions (like quote=double, or separator=",", but they simply do not work in Linux Mint 17. I think it's a bug.

Alfcx commented 10 years ago

Hi kiers

Pre-Check:

1.You have zenity and pdftk installed on your system, do you?

sudo apt-get update
sudo apt-get install zenity pdftk

  1. Do other nemo-actions from my repository work for you?

If yes:

Short Answer:

I also think, there's issue with Nemo Actions in Linux Mint 17. I'm on Linux Mint 16 and with yesterday's changes the pdf-merger script works with spaces in directory-names and filenames.

Long Answer:

I may can help you with an explanation of the changes I did yesterday.

Changes in pdf-merger.nemo_action

  1. The exec no longer sends the path of the files as an argument to the shell script. I also removed the "" around %F. The only Arguments passed to the shell script now are the full filenames.
    Exec=<"pdf-merger/pdf-merger.sh" %F>
  2. I added the Quote=double flag (without this setting it doesn't work on Linux Mint 16)

Changes in pdf-merger.sh

The pdtk command now works with all the arguments (filenames) passed by the pdf-merger.nemo_action in exactly the form they are passed ("$@").

pdftk "$@" cat output "$dir/$OUTPUTNAME.pdf" ;

As a result of the changes above I also had to change the variables (inputfiles and dir) at the beginning of the script.

Changelog

Here's a complete overview on the changes.

My thoughts

I also experimented with the seperator=... flag without success.

In my opinion the lack of support of filenames with spaces can only lay in the way nemo-actions passes the arguments to the shell script (because the shell script now uses the arguments exactly in the form they are passed by nemo-actions, as you can see above). Another explanation would be, that there was a change in pdftk, but that's way less likely.

I really have no idea ho to resolve this issue. I've made the experience that nemo-actions is poorly documented. So it's a nice thing if it works, but a pain in the a\ if it doesn't.

I hope my thoughts above can help you to find a solution. I'm interested in every progress you make, so feel free to post it.

Sincerely Alfcx

kiers commented 10 years ago

Hello Alfcx,

Thank you for your timely responsive help in this matter. I am surprised there is so much change between Mint 16 and Mint 17! (for the worse too)! (have not played with Mint 15 (which introduced/debut nemo-actions) nor Mint 16.)

I agree, it's not pdftk.

The interesting bit for Mint 17 is that the "full" filenames with path generated from %F are presented with spaces (in basename) that are NOT escaped (at least in Mint 17, have not tried others)

However, this of itself is not too much problem b/c user can process arguments (stream) via sed to correctly "escape" spaces in own wrapper script (mergepdf.sh) to correct this.

Nonetheless, apparently, according to Mr Webster (admin for nemo i presume) :

"So, no matter what, if you use (with the double quotes): "/home/mtwebster/foo\ bar/more\ foo/test.py" the escape characters do not get absorbed, and you have an invalid path there. The same goes with single quotes (which is supposed to behave this way anyhow)." (https://bugs.launchpad.net/linuxmint/+bug/1330225)

Alfcx commented 10 years ago

Hi Kiers

I had a look at your nemo-actions bug description at launchpad. According to that your exec is Exec=./wrapper.sh %F. May it would help, if you gave the following a try: Exec=<./wrapper.sh %F> or Exec=<"./wrapper.sh" %F>.

Alfcx

kiers commented 10 years ago

Hello, Putting <....> not required b/c full path, putting " " results in script not being called at all.

actually I had the whole path to wrapper.sh starting from root, in the Exec...ie. /home/...etc (this is not shown in launchpad for brevity)

plus i had plenty of debug output (echo "$@" >> to file etc) so there was no doubt shell was being executed.

I am still shocked how something so simple and ALREADY WORKING in Mint 15,16 is NOT in 17. Why would be broken the doublequote functionality within nemo actions file? amazing.

Invoking the wrapper in shell with command line argument string...WORKS Invoking the wrapper by passing THE SAME %F from pdftk...NO Have you loaded Mint 17 yourself?

Alfcx commented 10 years ago

Hi kiers I haven't loaded Mint 17 yet. I recently switched to Arch64 with gnome3. I think I'll stay with that, but I'll try out Mint 17 in a Virtual Box as soon as possible.

Ghostbird commented 7 years ago

I've had a similar problem on Debian Testing w/Cinnamon recently. It can be solved by using xargs to handle the arguments. I don't have the code with me at the moment though.