This may be of interest for bat file programmers out there. This simple command-line tool can be used to split a path ("C:\Some\Path\To\Split\File.txt") into its separate components.
"C:\Bin\WDDirSplit.exe" "C:\Some\Path\To\Split\file.txt" "C:\temp\uniquefilename.bat" Call "C:\temp\uniquefilename.bat" Del "C:\temp\uniquefilename.bat"
The above command will write batch SET statements for all path components to "C:\temp\uniquefilename.bat". Please note that the bat file (2nd parameter) will be overwritten if it already exists.
The contents of the generated bat file for the above command is:
rem How many components were found in path "C:\Some\Path\To\Split\file.txt" SET WD_DP_COUNT=5 rem WD_DP_1 has the first component ("Some"), WD_DP_2 the second... SET WD_DP_1=Some SET WD_DP_2=Path SET WD_DP_3=To SET WD_DP_4=Split SET WD_DP_5=file.txt rem WD_DPR_1 has the last component ("file.txt"), WD_DPR_2 the one before it..(R=Reversed) SET WD_DPR_1=file.txt SET WD_DPR_2=Split SET WD_DPR_3=To SET WD_DPR_4=Path SET WD_DPR_5=Some rem For conveniance: WD_DP_FIRST and WD_DP_LAST SET WD_DP_FIRST=Some SET WD_DP_LAST=file.txt