*SOLVED* Need some advice on a script i'm making

*EDIT* Solved, below code boxes have been updated to the code that works, thanks!

So I am working on a small script to use for a right-click option in Pcmanfm, it uses Imagemagick and Yad and is simply an image re-sizer, when you hover over an image in Pcmanfm it offers you the option "Resize Image For Web". Clicking it causes a small yad dialog to open and prompts you to enter a size, then the Imagmagick Convert script resizes it and converts it to a jpg, and adds the new size in the new copy's filename. (i.e. image.png becomes image-800x600.jpg).

It all works fine with one exception, currently when called with the .desktop action file, it drops the copy into the users Home folder instead of the current directory.

However it works perfectly if you open a terminal in the folder where the image is, and use

shrink2 name-of-image.whatever (target image file name)

it will spit out the copy right where you are at.

Any help would be greatly appreciated, no combination of output specifiers works so far in the convert command, no amount of $PWD or %f seem to work.

Re: *SOLVED* Need some advice on a script i'm making

Thanks guys, got a good link from another awesome Devuanista on IRC and found the way, had to use another double .desktop command, added a cd first to tell the shell where to execute the shrink script, so the exec line in shrink.desktop now is:

Exec=sh -c 'cd %d && shrink2 %f'

And it works great now, cool little extension for Pcmanfm I think, quick too, I just wanted something so you don't have to open gimp just to do a quick re-size.

I'll edit first post and mark solved.

But now i'm doing a similar extension just to rotate images, works but for some reason Pcmanfm isn't replacing the thumbnail preview with the correct rotated one, but that's for another post I guess.