How to replace a string with a substring when there are parentheses in the string
问题 I have been scratching my head for the last two days trying to put together a code that reads a folder structure and the strips off the base path of the listing. What I have so far is this: @ECHO OFF CLS SETLOCAL EnableExtensions EnableDelayedExpansion SET "StartTime=%TIME: =0%" SET "Folder=%~1" IF "%Folder:~-1%"=="\" SET "Folder=%Folder:~0,-1%" FOR %%G IN ("%Folder%") DO SET "Archive=%%~nxG" ECHO Processing %Folder%... ECHO. PUSHD "%Folder%" FOR /F "DELIMS=" %%G IN ('DIR /A:-D /B /O:N /S')