Script cannot load video date data

Advanced Renamer forum
#1 : 15/04-20 15:20
Lit
Lit
Posts: 5
if(item.extension == '.MP4')
{
nName = app.parseTags('<Video Date Year><Video Date Month><Video Date Day>_<Video Date Hour><Video Date Min><Video Date Sec>(AX700)');
names[item.name + '.MP4'] = nName + '.MP4';
return nName;
}
else
{
return names[item.name];
}

I wrote a script above for rename my sony camcorder video files.

[original]
C0001.MP4
C0001.MP4.modd
C0001.MP4.moff

[new]
20200415_120024.MP4
20200415_120024.MP4.modd
20200415_120024.MP4.moff

It should work like this. But app.Parsetags function won't work well.

It cannot load the video date tags.


15/04-20 15:20
#2 : 15/04-20 20:49
David Lee
David Lee
Posts: 1125
I'm not sure how your script is supposed to work - it appears to be riddled with errors!

However, as you say, Video Tags do not appear to be parsed by app.parseTags.

You can achieve the desired result in two passes, without using a script.

Make sure that "Pair renaming" is enabled and load all your files into the list

First Pass:

Remove ".MP4" from the filenames using "Replace"...
Text to be replaced: ".MP4"
Replace with: blank
Apply to: "Name"
(The .MP4 EXTENSION will not be removed)

Run the batch and reload all the files back into the list by selecting Add files: "All items" in the "Progress" window.

Now ARen will recognize the .modd & .moff files as file pairs of the .mp4 files (since all three filenames are now identical) and so they will be renamed to match the corresponding .MP4 files.

Second Pass:

1) New Name method...
New Name: <Video Date Year><Video Date Month><Video Date Day>_<Video Date Hour><Video Date Min><Video Date Sec>.MP4
Apply to: Name
(This will leave the .MP4 filename containing a redundant ".MP4".

2) Replace method (in the same batch)...
Text to be replaced: "MP4"
replace with: blank
Apply to: "Extension"
(The .MP4 extension will be deleted whereupon the ".MP4" in the filename will become the new extension - the .modd & .moff files will remain unaffected).

Run the second batch and all done.


15/04-20 20:49 - edited 15/04-20 20:52
#3 : 16/04-20 02:54
Lit
Lit
Posts: 5
Reply to #2:
Hi David Lee.

Thank you for reply. I know that I can do same work without script but I should run ARen twice so I'm trying to replace it with script.

I didn't said that I used global variable.

I used global variable like below.
var names = {};
So script can remember the original name and changed name in object names.

I just want to know why video date tags cannot loaded to script.

Is there a way to use video date tags in script?


16/04-20 02:54
#4 : 16/04-20 16:10
David Lee
David Lee
Posts: 1125
Reply to #3:

Hi Lit,

I've just learned something new as well! My usual JavaScript resource is very clear that:

"JavaScript does NOT support arrays with named indexes.
In JavaScript, ARRAYS always use NUMBERED INDEXES."

... which is why I couldn't understand how your script could possibly work.

However - reading a bit further I see:

"WARNING !!
If you use named indexes, JavaScript will redefine the array to a standard object.
After that, some array methods and properties will produce INCORRECT RESULTS."

So effectively you CAN use text indexing in many cases.

Thanks for the info - it will be very useful.

Regarding video date/time tags - there is obviously an issue with the implementation in scripting - I suggest that you email the developer - Kim Jensen - at [email protected] with a bug report.


16/04-20 16:10