I have a directory with a set of subfolder, matching a name pattern, like:
sub-123 sub-0815 sub-4711
Inside this folders I have some files with the same number on the name as it has been found in the folder name. e.g. the folder sub-123 contains the files
I want to iterate the folder, change the working directory to the current folder, and make some processing with the appropriate set of files. While I can iterate the folders with
for /d %%d in (sub-*) do .
I need the portion of the folder name, what matched the asterisk, in the example above "123". How can I extract the 123 from the folder name and build a command like
cd sub-123 copy input-123 output-123
inside a Windows-7 batch file? In the Linux environment it might be possible to use the cut command or any regular expression. But how should I go in Windows command prompt?