Naming files through looped batch

I have a question regarding how to get a looped script to name out projects and files using the same of name as the individual folders.

I have a working bat. file that will loop out a Reality Capture process. This script will run through the “Person_##” folders.

sample.tif (449.1 KB)

What I am aiming to do is to get the project saves and exports to be named after the folder, rather than the default place holder I have in the script (In this case, for the project be saved as Prop.rcproj, I want it to be instead, Person_01.rcproj for the first loop, and then Person_02.rcproj for the 2nd loop. Same for the export, for the first loop to export as "Person_01_Unedited.obj etc.

Is this possible through a batch script, or will the files have to be named manually after the script?

:: root path to work folders where all the datasets are stored (%~dp0 means the folder in which this script is stored)
set RootFolder=%~dp0

:: path to RealityCapture application
set RealityCaptureExe="C:\Program Files\Capturing Reality\RealityCapture\RealityCapture.exe"

::Create loop on which to run RC for all subfolders
:: for /R %%f in (%RootFolder%\..) do >>runscriptrealitycapture

for /D %%f in ("%RootFolder%*") do (
        ::echo Processing folder: '%%f'^

        :: run RealityCapture
        %RealityCaptureExe% ^
                -newScene ^
                -addFolder "%%f\Images" ^
                -detectMarkers ^
				-importGroundControlPoints "%~dp0DetectPositions.txt" ^
				-align ^
				-save "%%f\Project\Prop.rcproj" ^
                -selectMaximalComponent ^
				-setReconstructionRegion "%~dp0Prop_Basic_Rec_Box.rcbox" ^
				-calculateHighModel ^
				-save ^
				-selectLargestModelComponent ^
				-invertTrianglesSelection ^
				-removeSelectedTriangles ^
				-renameSelectedModel "Unedited" ^
				-exportSelectedModel "%%f\Outputs\Unedited.obj" "%~dp0Default_Model_Coordinate.xml" ^
				-save ^
                -quit
)

I think you can just use %%f to fill in with “person_x”

-exportSelectedModel "%%f\Outputs\%%fUnedited.obj"

let me know if that does the trick, also you need a line that makes the output folder if it does not already exist.