比如:第一个文件夹H114文件夹内有以下命名的图片文件:
1、H1140009-F7C8LF-29-GW0102-OneSize-NO3-White-1-1-printArea-4860965.jpg
2、H1140009-F7C8LF-29-GW0102-OneSize-NO3-White-1-2-printArea-4860965.jpg
3、H1140004-CNR9M9-1-GW0103-OneSize-NO1-White-1-1-printArea-3831295.jpg
4、H1140004-CNR9M9-1-GW0103-OneSize-NO1-White-1-2-printArea-3831295.jpg
这个文件夹要分成两个文件夹,分别把1放入GW0102-1文件夹,把2这个图片放入GW0102-2这个文件夹。然后3、4这两张图片要放入GW0103这个文件夹内。第二个文件夹内H160文件夹内文件名字如下:
1、H1620001-EE2S7G-1-SG7080-27.5_x55_-NO1-White-1-printArea-4812860
2、H1620004-FQ4GUD-1-SG7080-31.5_x63_-NO1-White-1-printArea-4814306
3、H1620017-G8I8I6-1-SG7313-OneSize-NO1-White-1-printArea-4814536
这个文件夹要把1放入SG7080-800文件夹内,把2放入SG7080-900文件夹内,把3放入SG7313这个文件夹内。代码如下:- cd /d "%~dp0"\H114"
- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /a-d/b "*GW0102-*-*-*-*-1*" 2^>nul') do (
- set /a n=1
- setlocal enabledelayedexpansion
- if not exist "GW0102-!n!" md "GW0102-!n!"
- move "%%a" "GW0102-!n!"
- endlocal
- )
- for /f "delims=" %%a in ('dir /a-d/b "*GW0102-*-*-*-1-2*" 2^>nul') do (
- set /a n=2
- set "f=%%a"
- setlocal enabledelayedexpansion
- if not exist "GW0102-!n!" md "GW0102-!n!"
- move "%%a" "GW0102-!n!"
- endlocal
- )
- for /f "delims=" %%a in ('dir /a-d/b "*GW0103*" 2^>nul') do (
- if not exist "GW0103" md "GW0103"
- move "%%a" "GW0103"
- endlocal
- )
-
- cd /d "%~dp0"\H160"
- @echo off
- setlocal enabledelayedexpansion
- for %%a in (*.jpg) do (
- for /f "tokens=4,5 delims=-(" %%i in ("%%~na") do (
- if not exist "%%~i-%%~j\." md "%%~i-%%~j"
- move "%%~a" "%%~i-%%~j\"
- )
- )
复制代码 但是这个代码只能分H160的,却不能分H114这个文件夹,如果单独使用的话又可以。请问下要怎么合在一起呢? |