Add delay to export + import to and from the same file in action?

This is my action to calculate the average bitrate for non-flac albums and store that as for example [MP3 255] at the end of the album tag.
When I use variables in the path for this export action:

$loop(%_filename_ext%)
$puts(Vbitrate,$add($get(Vbitrate),$mul(%_bitrate%,%_length_seconds%)))
$puts(cnt1,$add($get(cnt1),%_length_seconds%))
$loopend()
$div($get(Vbitrate),$get(cnt1))

I get "could not access file" errors on execution.
However, if I use an absolute path like "D:\rips\average bitrate.txt" I get errors the first time but once the text file is created, consecutive runs work.. kind of.

They lag 1 execution behind and store the value of the previous run in the tag.

Example:
I use it on an album with 320kBit/s mp3s -> 320 gets stored in the .txt
I use it on an album with ~255kBit/s mp3s -> 255 gets stored in the .txt file but 320 ends up in %custom1% and the album tag.
When I then rerun the action on the same ~255kBit/s mp3s folder it receives the correct value.

I'm not sure if that's the case, but could the action run too quickly and try to access the text file before it was finished being written to? In that case adding a delay between actions (even as little as a second) within an action group could resolve my problem (if that is possible).

That should also enable me to use "D:\rips%albumartist% - %album%.txt" in theory, meaning I could run my action over multiple folders without errors, which I would like.

So far I use it twice on each folder and that works well enough but I'd like to improve it.

Did you have a look at the documentation about the export action?

"Export actions are always executed after all other actions regardless of their position in the actions list. This is by design."
So your import looks at a file that first has not been written yet, later, the same action group imports the previous export.

That's a pity. Guess I'll have to split my action group in 2 and run those one after another or continue to run the current one twice for each folder. Thanks.

Edit:
In case someone stumbles upon this later on:
I got it to work like I wanted by making 3 action groups in total.
Group 1 exports to $validate(%albumartist%) - $validate(%album%).txt
Group 2 imports from $validate(%albumartist%) - $validate(%album%).txt and adds [MP3 255] for example to the album tag.
Group 3 modifies the _DIRECTORY field to move/rename the current folder with all its contents to one that resembles the new album name.

I put these 3 in submenus and named them:
&C ALBUM#&B Average Bitrate Export
&C ALBUM#&C Average Bitrate Import
&D DIRECTORY#&B album
resulting in
Alt + A + C + A
Alt + A + C + B
Alt +A + C + D
as hotkeys. I used these to create 1 macro per action for my keyboard. Now I merely press 3 macro keys from left to right (after the previous action has run through) and am done.

Not as elegant as I would've liked but it'll work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.