## Display clip (file) name?

duofuan
Posts: 7
Joined: Sun May 27, 2018 3:18 am

### Display clip (file) name?

Hi.

I'm completely new to fusion. I would like to create a script of setting to get a file name, take a part of it and display it as lower 3drs.

Could you help me?

Cheers!

Midgardsormr
Fusionator
Posts: 1020
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 53 times
Contact:

### Re: Display clip (file) name?

This thread will get you started:

viewtopic.php?p=10922#p10922

Parsing the filename so you're not showing the entire path can be done with bmd.parseFilename(), which is described in the scriptlib.lua file in your Scripts folder. For your convenience, here is the documentation from that file:

Code: Select all

------------------------------------------------------------------------------
-- parseFilename()
--
-- this is a great function for ripping a filepath into little bits
-- returns a table with the following
--
-- FullPath	: The raw, original path sent to the function
-- Path		: The path, without filename
-- FullName	: The name of the clip w\ extension
-- Name     : The name without extension
-- CleanName: The name of the clip, without extension or sequence
-- SNum		: The original sequence string, or "" if no sequence
-- Number 	: The sequence as a numeric value, or nil if no sequence
-- Extension: The raw extension of the clip
-- Padding	: Amount of padding in the sequence, or nil if no sequence
-- UNC		: A true or false value indicating whether the path is a UNC path or not
------------------------------------------------------------------------------

In Andrew's example comp, the Text+ tool's Styled Text input has this expression:
Text(self:GetSourceTool("MetadataSource").Output.Metadata.Filename)
which will show the full path of the current file. You can use parseFilename() to take just the part you want like so:
Text(bmd.parseFilename(self:GetSourceTool("MetadataSource").Output.Metadata.Filename).CleanName)

To break that down a little, working from inside to outside, self:GetSourceTool() will return the tool connected to an input, in this case "MetadataSource", which is the name of the custom image input that was added to the Text+ tool. The tool that we get in this fashion is assumed to have a standard output called Output, and you can read metadata off it, one field of which will be the filename. So we have someTool.Output.Metadata.Filename, which returns the full path of the image. That is what you feed to parseFilename().CleanName, which returns the CleanName field from the table described above. And, finally, Text() returns a Text object that the Text+ tool can use.

If you were doing this in a script, you'd probably assign variables for each piece, making it easier to read, but that's more difficult to do in a Simple Expression (not impossible, but probably more trouble than it's worth in this case).

duofuan
Posts: 7
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

duofuan
Posts: 7
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

After trying many times different variations finally I've found the variation witch works for me:
in text+ node the expression is : self:GetSourceTool("MetadataSource").ClipName

The ones in your example didn't work at all.

Now the question is - how to apply this comp to all clips in my timeline at once?

Iddos
Posts: 9
Joined: Sat Oct 06, 2018 4:21 pm

### Re: Display clip (file) name?

Now the question is - how to apply this comp to all clips in my timeline at once?
You can try using resolve script API to import fusion comp onto every clip in timeline.