Macro doesn't work if the previous actions failed

Import Nuendo Video And Audio V3.kmmacros (338.6 KB)
Hello!

The attached macro should import audio and video files into Nuendo.
It works correctly if there are audio and video files exist in the selected folder.
But it doesn't work if there is no audio and only video in the folder.
Please help me to figure out why.
Thanks!

Either use the Debugger (available from the KM menu bar icon) to step through your macro to find the error -- instructions on how to use it are here: Macro Debugger -- or liberally add "Display text" actions to your macro to find out where it is going wrong.

But if I had to take a guess based on your description -- if there's no audio files you aren't importing any audio tracks. So Nuendo won't be in the expected state when the "Set Time-Code from audio" group runs. You need to change your "If" test because the "last action result" is "OK" even when there's no audio to import. Maybe test for the presence of a menu item instead, or set a "Local_hasAudio" variable if a track is imported.

1 Like

Yes, you are right. If I exclude the timecode group, it works. But I am not sure why as in the timecode group I have "otherwise" action if the audio import fails.
Actually it would be easier to set the condition If "wav file exists in the specified folder". But I couldn't figure out how to do that except the For Each action.

Ah, but you don't. You're checking the "last action result" -- was the last action executed without an error -- rather than something being true or false.

Consider this:

Last Action Result Demo.kmmacros (3.4 KB)

It doesn't matter if the "If..." is true or false, the dialog is still "OK". When true it's because the "Set Variable..." action completed without error. When false it's because the "If..." action completed without error (because there's no action in the "otherwise" section).

You could do it by:

  1. Setting a variable Local_wavFile to false before the "Import Audio" block
  2. Including a "Set Local_wavFile to true" in the "execute if true section of each of the "Import..." blocks
  3. Testing Local_wavFile in your "Time-Code" block

But the easiest way is to test directly, with a shell script, if the directory you are importing from contains any files ending with .wav. I think this will do it, but do check I've used the right variable:

Set Time-Code.kmactions (5.7 KB)

Set Time-Code

1 Like

Thank you so much for the comprehensive response! It works perfectly!

I am sorry, I didn't check the shell script version. For some reason it doesn't work.
I've tried to use it here:

The path contains the wav files but macro doesn't work. It doesn't type the Key Command and run the Import Audio dialogue

Import Nuendo Video And Audio TEMP.kmmacros (295.2 KB)

This simple macro doesn't work either

Can it be related to sequoia?

I am not well versed enough in shell scripting to really see why, but I am not able to make this script return a success here either, and I am still on Ventura.

I might be missing what you are trying to do here now, but if it is to check if a file selected in finder is in fact an existing .wav file it could also be done, for instance like this:

Test if Finder Selection is a .wav file SINGLE FILE SELECTION ONLY.kmmacros (24 KB)

Macro Image

But as the %FinderSelection% token only wors with single selection (returning empty if more than one file is selected) this method will only work with a single finder selection, (the %FinderSelections% token, returning a line separated list of all paths in selection, would not here work directly within a Split Path either.) The way I've set it up above, with Faliure Abort Macro and Notify On Failure both turned off in the Split Path cogwheel menu, it will return 'not' of multiple files are selected, but this is probably not what you want, IF at all want to select multiple files, that is.

If you are interested in selecting multiple files, checking to see if all of them are .wav.files it could be set up like this, in a for each:

Macro Image, Method 1

But it might be better just setting it up as this:

Test if ALL FILES in Finder Selection are .wav files MULTIPLE SELECTED FILES POSSIBLE method 2.kmmacros (28 KB)

Macro Image, Method 2

Since the paths are all coming from a finder selection I believe it should not really be necessary to check if at the path, something exists, but this way it is at least thoroughly tested.

1 Like

That macro was a part of another macro to check if there any wav files in the selected folder.

I will try your solutions if they help me. Thanks!

1 Like

The shell script does not return success for me if selecting a folder with .wav files ether.

For checking a folders content you'd need to set the for each up like this, for method 2 to work with checking that all fles in that folder are .wav files:

If you want to check if in the folder there are .wav files, (but possibly also other file types), then you could set it up like this:

Test if in folder- selected in Finder- there are at least one .wav file — method 3.kmmacros (22 KB)

Macro Image

1 Like

Yes, I've already done a similar macro but with no Break From Loop (as I didn't know about this feature :slight_smile: )

Thank you!

...and...

That's my bad -- I missed a / between the variable and the *.

So you can either append a / to local_AudioFilePath before using the variable in the shell script, or (and probably better) change the script to:

ls "${KMVAR_local_AudioFilePath}"/*.wav

I didn't say but I tried to add / but it didn't work.

Do you actually have a folder containing WAVs selected in that window? %FinderSelection% requires an actual selection, not just an open window -- for that, use %FinderInsertionLocation%.

Yes, I have it selected. Sorry for the unclear screenshot.

Then make sure that the little drop-down menu next to the shell script box has either "All variables" or at least local_AudioFilePath selected:

image

It works fine on everything I've tested it on -- provided I haven't done something like missing the / out!

2 Likes

That's it! Thank you!

2 Likes