寻找一个脚本或batch file,根据部分文件名将主目录中的图片分类到各自的子目录

我有这样命名的文件,分为三部分,用连字符分隔。

Motorcycle-001-01.jpg Motorcycle-001-02.jpg Motorcycle-001-03.jpg Motorcycle-002-01.jpg Motorcycle-002-02.jpg Motorcycle-002-03.jpg 

文件名的第一部分表示摩托车的照片。 第二部分是系列,第三部分是系列中的个人画面。

我有一个叫Motorcycles的整个目录,有6000张左右的图片,这种方式一直到Motorcycle-238-150.jpg

我的问题是如果有一个batch file或脚本,我可以使用序列号或文件的第二部分sorting这些文件。 我想我的摩托车目录中的所有文件被移动到摩托车目录内的子目录。 例如,我想Motorcycle-001-01.jpg通过Motorcycle-001-150.jpg移动到目录001.然后Motorcycle-002-01.jpg到Motorcycle-002-135.jpg移到目录002和等等。

 @Echo OFF :: By Elektro H@cker REM Series: REM If you type "1" it's equals to serie "001" REM If you type "10" it's equals to serie "010" REM If you type "100" it's equals to serie "100" REM You can change that at the pattern multi-comparisions :: Introduces a number of serie... :SELECT Set /P "Serie=Select the serie to move >>" :: Basic error handling Echo "%SERIE%" | FINDSTR /I "[az]" 1>NUL && ( Echo [-] Type only nums... Set "Serie=" GOTO:SELECT ) :: Set the correct pattern for selected serie IF %SERIE% LEQ 999 IF %SERIE% GTR 99 (Set "PATTERN=%SERIE%") IF %SERIE% LEQ 99 IF %SERIE% GTR 9 (Set "PATTERN=0%SERIE%") IF %SERIE% LSS 999 IF %SERIE% LSS 99 IF %SERIE% LEQ 9 (Set "PATTERN=00%SERIE%") :: Makes the serie directory MKDIR ".\%PATTERN%\" 2>NUL :: Move all the files of the serie to the folder For /F "Tokens=*" %%@ in ('DIR /B "Motorcycle-%PATTERN%*"') do ( Move "%%@" ".\%PATTERN%\" >NUL Echo [+] Moved: %%@ ) Pause&Exit