0

I was wondering if someone could help me edit an answer to the previous question:

.bat file sorting files into folders

I want to do something similar to that code. I want to sort files into folders using a section of the name, except rather than using the last 10 characters I want to use the 10th to the 20th character of the name. Thanks for any help!

SETLOCAL ENABLEDELAYEDEXPANSION
for %%a in (*.jpg) do (
set f=%%a
set g=!f:~0,10!
md "!g!" 2>nul
move "%%a" "!g!"
)
Community
  • 1
  • 1

1 Answers1

2

set g=!f:~0,10! takes a substring, starting from the first one (starts counting at 0!), with the length of 10.

If you want to start with the tenth char, keeping the lenght of ten, use set g=!f:~9,10!

See set /? for more information.

Stephan
  • 53,940
  • 10
  • 58
  • 91