user iconPeterJZ on February 14th 2010
9753 views

topic iconResize and rename in same folder

I am struggling to rename and resize a file in the same folder. Here is the code

While Not rstGen.EOF
     strSourceImage = me.txtSource
     strDestImage = me.txtDest

     RetVal = Shell("PhotoResize500ICOG.exe" & "-i" & strDestImage, strSourceImage,vbHide)

     rstGen.MoveNext
Wend

I have spent many hours on this problem, even using the wizard, the solution escapes me.

Thanks for your help

user iconVlasta on February 14th 2010 0

There are some examples in the comments section accessible from the homepage of the tool.

I do not work in VB, but the I letter and -i switch actually inverts the in-place flag, so I guess one cancels out hte other. Furthermore, it may be possible that the result of "PhotoResize500ICOG.exe" & "-i" is "PhotoResize500ICOG.exe-i" and that is probably not valid.

user iconPeterJZ on February 15th 2010 0

Thanks for the reply. I have read the comments section but it does not apply to my specific question. The "-i" was a mistype; I meant " -i" which I think then represents a command line parameter.

Thanks for your help.

user iconVlasta on February 15th 2010 0

OK, but it still cancels the I in filename out.

user iconPeterJZ on February 15th 2010 0

Vlasta, I really appreciate your help, but I am still stuck. For clarity I have reworked the code somewhat, and used the .exe file without any additions (such a OCG, for example), relying on the command line switches only:

strResizeApp = "PhotoResize500.exe"

While Not rstGen.EOF                               'rstGen is a recordset with files from the source folder
     strSourceImage = rstGen("ImgPath")           'full path to source, eg. c:\images\img100_123.jpg
     strDestImage = strDest & rstGen("ImgName")   'full path to destination, eg. c:\images\img_500.jpg

    RetVal = Shell(strResizeApp & " -n -q80 -o -i""" & strDestImage & """  """ & strSourceImage & """", vbHide)

     rstGen.MoveNext
Wend

The code executes without a hitch, but the fie does not get renamed.

If I change the -i in the command line to -c and use a different source folder, the code works perfectly.

Therefore, I manage to copy & resize between folders, but not within the same folder. I thought I only needed to change -c to -i, but that clearly is not the case.

Any suggestions?

user iconVlasta on February 15th 2010 0

It is hard to find problems by just reading a code, but I'll try. -i has no additional parameters, so try to remove the dest folder. BTW, if -c was there before, I suppose it did not work either. The quotes should be used for example like this "-cC:\My Pictures\<NAME>.jpg" - around the whole switch, NOT like -c"C:\My Pictures\<NAME>.jpg".

Try:

strResizeApp & " -n -q80 -o -i """ & strSourceImage & """"

I would recommend to test the tool on command line and move to scripting if it works as expected. In case of problem, sending the command line to screen before executing can help locate problems.

user iconPeterJZ on February 15th 2010 0

Perhaps I am trying to do something that PhotoResizer cannot do. Could you please confirm that it is possible, given the correct commands, to resize and rename an image in the same folder with one command?

Again, thanks for your time and patience.

user iconVlasta on February 15th 2010 0

Yes.

The -i switch overwrites the original file.

The -c switch allows you to control the destination path and name.

user iconPeterJZ on February 15th 2010 0

Vlasta, forgive me for taking so much of your time, but I find these command line switches hugely confusing. To tell you the truth, I cannot even get the command line to function properly in the Run window.

Can you please tell me what is wrong with the following code? I am trying to resize a file while renaming it at the same time:

c:\images\PhotoResize500ICO.exe c:\images\newname.jpg c:\images\oldname.jpg

When I run the command, nothing happens, neither the resize nor the rename.

Thanks for your patience.

user iconVlasta on February 15th 2010 0
c:\images\PhotoResize500O.exe "-cc:\images\newname.jpg" "c:\images\oldname.jpg"

(Quotes are not needed in this concrete case.)

Switches -i and -c (or I and C) are exclusive and -c is different from C in filename. You cannot simultanously put the output to current folder, original folder, and custom folder.

user iconPeterJZ on February 15th 2010 0

Thanks a million, Vlasta, you are a star!

user icon