Can't create ouput file when using -o option and relative path [Solved]

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Welsh
Posts: 2
Joined: Sat Mar 02, 2024 4:56 pm

Can't create ouput file when using -o option and relative path [Solved]

Post by Welsh »

Hi all

As I'm trying to use nconvert within a btach file under windows, I'm facing a problem using relative paths.
Here it is :

Initial directory structure

Code: Select all

- originals
    - family
        - doe
              file.jpg
        - smith
    - friends
- web
I just want to resize every file in the whole originals directory structure and put the results in web directory reproducing the directory structure.
So I use this commande line in a batch file :

Code: Select all

for /f %%I in ('forfiles /s /m *.* /c "cmd /c echo @relpath"') do nconvert  -ratio -rtype lanczos -rflag decr -rflag orient -resize 1920 1200 %%~I -o "..\web\%%~I"
It looks good but when executing it i face a message

Code: Select all

Error : Can't open file (-o)
Error : can't open file (..\web\.\family\doe\file.jpg)
I just copy one line command which is a result like :

Code: Select all

nconvert  -ratio -rtype lanczos -rflag decr -rflag orient -resize 1920 1200 .\family\doe\file.jpg -o "..\web\.\family\doe\file.jpg"
Am I missing something ?

Thanks in advance
Last edited by Welsh on Sun Mar 03, 2024 10:37 am, edited 1 time in total.
Welsh
Posts: 2
Joined: Sat Mar 02, 2024 4:56 pm

Re: Can't create ouput file when using -o option and relative path [NConvert 7.121]

Post by Welsh »

Hi all

I was missing something...
My command line is :

Code: Select all

nconvert  -ratio -rtype lanczos -rflag decr -rflag orient -resize 1920 1200 %%~I -o "..\web\%%~I"
But nconvert command line should be

Code: Select all

nconvert options file
So my command line is treated as if `-o "..\web\%%i"` should be 2 files to be processed..

So putting the command line members in right order and everything is ok.

Code: Select all

nconvert  -ratio -rtype lanczos -rflag decr -rflag orient -resize 1920 1200 -o "..\web\%%~I" %%~I
Sorry this mistake.
cday
XnThusiast
Posts: 4132
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Can't create ouput file when using -o option and relative path [NConvert 7.121]

Post by cday »

Welsh wrote: Sun Mar 03, 2024 10:36 am I was missing something...

My command line is :

Code: Select all

nconvert  -ratio -rtype lanczos -rflag decr -rflag orient -resize 1920 1200 %%~I -o "..\web\%%~I"
But nconvert command line should be

Code: Select all

nconvert options file
So my command line is treated as if `-o "..\web\%%i"` should be 2 files to be processed..
Thanks for reporting back!

I have always used the order shown, but didn't question your order as I have recently been wondering if it was actually needed, and as far as I know it is not formally documented.