Using New Name in Output Folder path

Is there a way to use the New Name to construct the Output folder path?

I use multiple methods and conditions to rename image and video files <YYYYMMDD>-<HHmmss>-<SHA1>.<ext>. The renaming with the conditions works great, ensuring all my files have that naming convention. I'd like to create an output path that uses like
...\Staging\<Name:substr:1:4>\<Name:substr:5:2>

...picking up the year and month from the new name. Of course, what I have above picks up the original name. Is there any way to get at the New Name for the output path?

I can't just use something like <Img Year>\<Img Month> for the output folder because I have to fallback to <Date Created> and <Time Created> for some files. That's where the conditions come in. But via the methods and conditions I have set up, I do arrive at a solid New Name so I'd like to use that name to structure the files into a Year\Month folder structure.

Thoughts?!

I guess I could run it as two separate batches: 1) do the file renames, 2) do the Move or Copy to the desired folder structure.

Reply to #1:

Hi Kevin,

You can add a script method at the end, containing this:

let n = item.newBasename ;
item.newPath = "F:\\whatever\\Staging" + "\\" + n.substring( 0, 4 ) + "\\" + n.substring( 4, 2 ) + "\\" ;


NOTE: I recommend that you include the full path, as I've done, in any "item.newPath" statement. Just be sure to use TWO backslashes at each directory level. Show the "New Path" column in your files list to check, and remember "Undo batch" in case they don't go where you expected. :)
EDIT: Always use the same drive for your target folder. Screenshot:
https://drive.google.com/file/d/1g3TCu-sDzHRNubHfWbE9k_2ul7M IXb0I/view?usp=sharing

Best,
DF