I am trying to extract the Parent_Folder name from a variable containing a full path\filename (with spaces). I've seen a few similar threads, but I cannot seem to successfully adapt to my approach.
@echo off
setlocal enabledelayedexpansion
set File1=filelist.txt
set File2=filelist2.txt
cd\users\mark\downloads\media
::Remove existing metadata files
for /f "delims=" %%f in (%File2%) do del "%%f"
::List current \Media files
dir /s/b *.mp4 *.mkv > %File1%
::Write metadata
for /f "tokens=*" %%a in (%File1%) do (
:: filename, no extension
set myFile=%%~na
:: full path, no filename
set myPath=%%~dpa
set myParent=????
echo title : !myParent! > %%a.txt
echo seriesTitle : !myParent! >> %%a.txt
echo seriesId : !myParent! >> %%a.txt
echo episodeTitle : !myFile! >> %%a.txt
echo description : !myFile! >> %%a.txt
echo isEpisode : true >> %%a.txt
echo isEpisodic : true >> %%a.txt
echo myPath : !myPath! >> %%a.txt
)
::Relist the metadata files
dir /s/b *.m*.txt > %File2%
Any suggestions how to grab "myParent" from "myPath"
Example: "c:\users\mark\this directory\some filename.mkv"
Should return: "this directory"
Thanks!