NConvert -recurse creates unwanted folders when folder depth is higher than 1

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

Moderators: XnTriq, helmut, xnview

mdnava
Posts: 18
Joined: Fri Mar 06, 2020 8:08 pm

NConvert -recurse creates unwanted folders when folder depth is higher than 1

Post by mdnava »

Using NCONVERT v7.192
There seems an issue with RECURSION in NConvert, when there's more than one level depth..
It creates multiple unwanted folders.

I made a sample video showing the issue..
https://www.youtube.com/watch?v=yhew32kusug
(video is not listed, only accesible thru direct link)

Command sample:

Code: Select all

$ nconvert.exe -recurse -rflag decr -out jpeg -q 85 -no# -o "$\_workspace_\%.jxl" "D:\mdnava\Workspace_L\20241107 TEST\*.*"
Important: The issue doesn't happen if recursion has a single depth, only when higher than that.

If there are multiple folders with images, they convert successfully.
-- folder1-with-imgs/
-- folder2-with-imgs/

But if there is multi lever recursion, there's a problem, as multiple subfolders are created for each image file
-- folder1/
---- subfolder1-with-imgs/
---- subfolder2-with-imgs/

-- folder2/
---- subfolder3-with-imgs/
---- subfolder4-with-imgs/

Result sample
-- folder1/
---- subfolder1-with-imgs/
------ subfolder1-with-imgs/imagename1-folder/imagename1-folder/imagename1.jpg
------ subfolder1-with-imgs/imagename2-folder/imagename2-folder/imagename2.jpg
------ subfolder1-with-imgs/imagename3-folder/imagename3-folder/imagename3.jpg
------ subfolder1-with-imgs/imagename4-folder/imagename4-folder/imagename4.jpg
------ subfolder1-with-imgs/imagename5-folder/imagename5-folder/imagename5.jpg
------ subfolder1-with-imgs/imagename6-folder/imagename6-folder/imagename6.jpg
------ subfolder1-with-imgs/imagename7-folder/imagename7-folder/imagename7.jpg
------ subfolder1-with-imgs/imagename8-folder/imagename8-folder/imagename8.jpg
---- subfolder2-with-imgs/
------ subfolder2-with-imgs/imagename1-folder/imagename1-folder/imagename1.jpg
------ subfolder2-with-imgs/imagename2-folder/imagename2-folder/imagename2.jpg
------ subfolder2-with-imgs/imagename3-folder/imagename3-folder/imagename3.jpg
------ subfolder2-with-imgs/imagename4-folder/imagename4-folder/imagename4.jpg
------ subfolder2-with-imgs/imagename5-folder/imagename5-folder/imagename5.jpg
------ subfolder2-with-imgs/imagename6-folder/imagename6-folder/imagename6.jpg
------ subfolder2-with-imgs/imagename7-folder/imagename7-folder/imagename7.jpg
------ subfolder2-with-imgs/imagename8-folder/imagename8-folder/imagename8.jpg

This becomes a huge problem when there are many image files..
User avatar
xnview
Author of XnView
Posts: 44929
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: NConvert -recurse creates unwanted folders when folder depth is higher than 1

Post by xnview »

if you use an output path, do you have same problem?

Code: Select all

nconvert.exe -recurse -rflag decr -out jpeg -q 85 -no# -o "D:\mdnava\_workspace_\%.jpg" "D:\mdnava\Workspace_L\20241107 TEST\*.*"
Pierre.
mdnava
Posts: 18
Joined: Fri Mar 06, 2020 8:08 pm

Re: NConvert -recurse creates unwanted folders when folder depth is higher than 1

Post by mdnava »

xnview wrote: Mon Nov 25, 2024 9:02 am if you use an output path, do you have same problem?

Code: Select all

nconvert.exe -recurse -rflag decr -out jpeg -q 85 -no# -o "D:\mdnava\_workspace_\%.jpg" "D:\mdnava\Workspace_L\20241107 TEST\*.*"
Hello Pierre.. Yes! I just tested it. But that question also gave the solution.
Using a specific output path makes flat the destination folder, containing at that level all images and recursive subfolders.

Code: Select all

nconvert.exe -rflag decr -recurse -out jpegli -q 85 -no# -D -overwrite -o "D:\mdnava\Workspace_L\20241107 TEST\TEST\%.jpg" "D:\mdnava\Workspace_L\20241107 TEST\TEST\*.*"
So, this:

"D:\mdnava\_workspace_\%.jpg"
-- folder1/
---- subfolder1-with-imgs/
---- subfolder1-with-imgs/a01/
---- subfolder1-with-imgs/a02/
---- subfolder2-with-imgs/
---- subfolder1-with-imgs/b01/
---- subfolder1-with-imgs/b02/
-- folder2/
---- subfolder3-with-imgs/
---- subfolder1-with-imgs/c01/
---- subfolder1-with-imgs/c02/
---- subfolder4-with-imgs/
---- subfolder1-with-imgs/d01/
---- subfolder1-with-imgs/d02/

Now becomes this:

"D:\mdnava\_workspace_\%.jpg"
-- a01/
-- a02/
-- b01/
-- b02/
-- c01/
-- c02/
-- d01/
-- d02/
-- folder1/
-- folder2/
-- subfolder1/
-- subfolder2/
-- subfolder3/
-- subfolder4/

——————————————————————————————
SOLUTION ??
——————————————————————————————

The question to try and use -o with a specific output path also made me try removing completely the -o parameter
because in the end this command is also using -overwrite .. so it should just replace the existing files.

Code: Select all

nconvert.exe -rflag decr -recurse -out jpegli -q 85 -no# -D -overwrite "D:\mdnava\Workspace_L\20241107 TEST\TEST\*.*"
And it worked!.
All files were converted and replaced the originals, on their correct original locations.

The issue happens when using -o "$/some/path" in conjunction with: -recurse -overwrite
So in a sense, NConvert seems to be actually doing what is supposed to do, overwrite and move around files.

Perhaps there should be a warning/confirmation when using these options together with -o "/some/path"?
Just a thought!. Probably not needed.
However, both -recurse and -overwrite are probably some of the most useful options in NConvert,
but also likely to be the most prone to disaster.

IMPORTANT: I did some more testing and this also seems to be the cause of this other issue:
NConvert: JPEG XL convert fails with Exit code -1073740791

Removing "-o <some/path>" when using also "-overwrite -out jpegxl" seems to have solved that issue.
However, at least for me, this other issue only happened for JPEG XL, weirdly enough not for any other format (like jpg or png).

Pierre, thank you for your help..
I believe both these issues are now solved by NOT using the -o parameter together with -recurse -overwrite

Best regards! :D