Setting metadata - file in use message

I have a small VB program that allows me to change the date created and t he date digitized on an image. It works perfectly well 99 per cent of the time. However, when I run the macro against files larger than about 5 megs, I get a message from Windows telling me that the the file is in use.

When I look in the lister I can see my file and also a temp file.

This is something I have seen before when setting large amounts of metadata from a VBscript. It is not life-threatening but it is annoying as you have to keep deleting the temp file before you can try again.

This always happens when the system is under some stress - e g there is an Acronis back-up being taken of the System Drive.

The code I use to set the dates is:

ClickData.Func.Command.AddLine("SetAttr META ""datetaken:" & datery & """")
ClickData.Func.Command.AddLine("SetAttr META ""datedigitized:" & datery & """")

where datery is a variable containing the date. This code is followed by a run command.

I surmise is that the first command is executed fine, but when the second command is run the file is flagged by the system is "in use" as the save has not been completed.

An obvious solution is to combine both commands in one SetAttrMeta. My problem is that I cannot work out the syntax for this command. Whatever I try, I keep getting syntax errors.

Could you give me some assistance, please into how such a single command should be parsed?

You can set both values at once, which will solve the problem:

SetAtr META "datetaken:xyz" "datedigitized:xyz"

Yes, I gleaned that from the help files, Leo.
My problem is how do I incorporate that into the VB command that I am running in my macro. That is what is defeating me. Everything I try gives a syntax error. Something to do with numbers of " marks I would guess.

Leo,
I have found the syntax - I was trying to make it far too complicated.

Many thanks for your prompt attention

Just remember that in VB, once you're within a "string", a "" inserts a single ". So four " marks in a row ("""") gives you a one character string equal to ".

Sorry Jon, I still just do not get it. As you will have realised, I am no programer .

Could you show me how I should adjust the command line I show above? Presently I am up to my eyeballs in quotation marks and all I get are either syntax errors of t he data is simply not written.

I would appreciate your help. Many thanks.

I thought you said you had it working?

Another way to do it which might be less confusing is to use Chr(34) outside the string. So as an example, a string a "b" c can be represented as:

  • "a ""b"" c" or
  • "a " & Chr(34) & "b" & Chr(34) & " c"

I thought i had it working, but it was not writing the metadata.

In the words of the famous sage: "There are many ways to confuse a cat" - but this has to be the best.

I understand your logic, it is just the application that is driving me nuts.

I have come up with:

ClickData.Func.Command.AddLine("SetAttr META ""datetaken:" & datery "" datedigitized:" & datery & """"""")

Of course, it errors demanding I put in a bracket.

I'm torn between giving a man a fish and teaching a man to fish :smile:

Count the quotes. A single " starts (and then ends) a string. Within the string a double " gives you a " character.

If you haven't got it in 12 hours I'll give you the answer :slight_smile:

Congratulations, you have taught a man to fish. I really appreciate your help and patience, Jon.