Using different input and output directories

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

Moderators: XnTriq, helmut, xnview

agdabn
Posts: 10
Joined: Tue Mar 02, 2021 9:30 am

Re: Using different input and output directories

Post by agdabn »

Yes, you're right!

I used -rmeta and -rexifthumb to remove the metadata. instead of-clean 95
I figured out how to make different folders of input and output files. here is the Code:

Code: Select all

@chcp 1251
@for /R "D:\images_input\" %%I in (*.jp*) do D:\NConvert\nconvert -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -q 70 -rmeta -rexifthumb -o D:\images_Output\%%~nI %%I
I still can't find the parameter of this button:
Replace.jpg
Replace.jpg (52.16 KiB) Viewed 2363 times
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Using different input and output directories

Post by cday »

agdabn wrote: Wed Mar 03, 2021 9:46 pm I still can't find the parameter of this button:
Replace.jpg
The new file will replace the existing file if you use the -D option suggested earlier... :D

Code: Select all

  -D                : Delete original picture
Always test with copies of files!

I'll look again at the rest of your post later.
agdabn
Posts: 10
Joined: Tue Mar 02, 2021 9:30 am

Re: Using different input and output directories

Post by agdabn »

In this case,- D will not help.
After all, the original file is located in a different directory. And the replacement is necessary in the Output folder. I.e. if there is already a file with this name in the Output folder, then it must be replaced.
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Using different input and output directories

Post by cday »

agdabn wrote: Wed Mar 03, 2021 10:20 pm In this case,- D will not help.
After all, the original file is located in a different directory. And the replacement is necessary in the Output folder. I.e. if there is already a file with this name in the Output folder, then it must be replaced.
Alright, not the same thing... :(

Maybe this option, I've never used it, or even noticed it before:

Code: Select all

 -overwrite        : Overwrite existing file

Always test with copies of files!
agdabn
Posts: 10
Joined: Tue Mar 02, 2021 9:30 am

Re: Using different input and output directories

Post by agdabn »

YES, super
Thank you very much.
Now everything works as it should. Final variation:

Code: Select all

@chcp 1251
@for /R "D:\images_Input\" %%I in (*.jp*) do D:\NConvert\nconvert -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -q 70 -overwrite -rmeta -rexifthumb -o D:\images_Out\%%~nI %%I
Jaymer
Posts: 3
Joined: Mon Aug 02, 2021 7:58 pm
Location: Howay the lads!

Re: Using different input and output directories

Post by Jaymer »

Gentlemen, thanks for your work on this issue.
I have a related question...

My upload directory for my website is where I need to resize the images... just to reduce the size of what users upload because too large a file is not needed.

BUT, in case of errors someday, I'd like to have a backup of the files.

How can I make a safe ORIGINAL-sized copy of a image BEFORE the nconvert?
I will output to the same directory, REPLACING the old file, so I need the safe copy made ONLY ONCE.
I'm doing this on Windows server, so I could use powershell to help me if there is no other way using nconvert.
Any ideas?
thx
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Using different input and output directories

Post by cday »

Jaymer wrote: Mon Aug 02, 2021 8:12 pm My upload directory for my website is where I need to resize the images... just to reduce the size of what users upload because too large a file is not needed.
So you run NConvert to resize (in pixel dimensions, or by changing the file compression, or both) and output to your website directory...

BUT, in case of errors someday, I'd like to have a backup of the files.

How can I make a safe ORIGINAL-sized copy of a image BEFORE the nconvert?
I will output to the same directory, REPLACING the old file, so I need the safe copy made ONLY ONCE.
When NConvert has finished running, your original files will still exist unaltered, so do you need to make a copy?

I'm doing this on Windows server, so I could use powershell to help me if there is no other way using nconvert.
Any ideas?
If you still need to make an identical copy, or you need to move the orignal files to a different directory, you could do that directly using Windows CMD or Powershell without having to consider how NConvert might alter the files when your code is run...

Or am I missing something? :wink:
Jaymer
Posts: 3
Joined: Mon Aug 02, 2021 7:58 pm
Location: Howay the lads!

Re: Using different input and output directories

Post by Jaymer »

the directory they are uploaded into is the dir. they will stay in.
i think i will use powershell to copy files to a new location, but test to see if it exists first. that way, only new files will get copied.

Is there any harm in running nconvert over and over on the same files? ... or any way to prevent this.
if my images dir holds 1000 files, and 5 new ones come in today.
I only need to resize 5 - but no real way to identify just those 5. I may process these a few times per day.
So when my script starts, nconvert will process 1005 files, but only 5 will need to be resized to my spec.
All the others will be skipped i guess?
Or will they still get re-written, even though the file didn't change?

Seems like a lot of wasted processing.
Maybe I could set archive bit at the end of my process, and powershell could only run nconvert on the files with NO bit set when it next starts (which would only be the new files)?
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Using different input and output directories

Post by cday »

Jaymer wrote: Mon Aug 02, 2021 8:57 pm Is there any harm in running nconvert over and over on the same files? ... or any way to prevent this.
That depends on whether the files are in a lossless or lossy format: if they are JPEGs the quality would be expected to be progressively degraded, using the option to 'save at the estimated original quality (when possible)' could minimise that, but it would still be unlikely to meet your needs.

You could in principle convert the files to a lossless format the first time your script is run, but depending on the type of images, whether photographs or line drawings for example, that could have a significant impact on filesize.

if my images dir holds 1000 files, and 5 new ones come in today.
I only need to resize 5 - but no real way to identify just those 5. I may process these a few times per day.
So when my script starts, nconvert will process 1005 files, but only 5 will need to be resized to my spec.
All the others will be skipped i guess?
No, they will all be opened and then resaved...

Maybe I could set archive bit at the end of my process, and powershell could only run nconvert on the files with NO bit set when it next starts (which would only be the new files)?
Something like that, I don't have detailed knowledge of Powershell or that level of knowledge of CMD either.
Post Reply