本帖最后由 yakeyun 于 2022-5-20 14:07 编辑
回复 1# 13545876873
贴主要表达的意思:
D盘存在如下两个目录:
D:\基因合成\2022.5
\5001\
\5002\
\5003\
D:\测序结果
\[K3746-5001-1-26-PUC57]M13-48_B03.ab1
\[K3746-5001-25-48-PUC57]M13-48_B03.ab1
\[T4567-5003-25-48-PUC57]M13-47_C03.ab1
\[V2001-5002-25-48-PUC57]M13-47_C03.ab1
需求读取D:\测序结果目录中的文件,根据5001、5002、5003字段分类文件,然后移动到D:\基因合成\2022.5\目录下对应字段文件夹中。
另存为ANSI格式,不然中文目录不会被识别。- @echo off&setlocal enabledelayedexpansion
- for /f %%a in ('dir /a /s /b "D:\测序结果\*.ab1"') do (
- set dvn=%%a
- for /f "tokens=2 delims=[]" %%b in ("!dvn!") do (
- for /f "tokens=2 delims=-" %%c in ("%%b") do (
- set mls=%%c
- set Ns=%date:~0,4%
- set Ys=%date:~5,2%
- if !Ys!==01 (set "Ys=!Ys:01=1!")
- if !Ys!==02 (set "Ys=!Ys:02=2!")
- if !Ys!==03 (set "Ys=!Ys:03=3!")
- if !Ys!==04 (set "Ys=!Ys:04=4!")
- if !Ys!==05 (set "Ys=!Ys:05=5!")
- if !Ys!==06 (set "Ys=!Ys:06=6!")
- if !Ys!==07 (set "Ys=!Ys:07=7!")
- if !Ys!==08 (set "Ys=!Ys:08=8!")
- if !Ys!==09 (set "Ys=!Ys:09=9!")
- set "today=!Ns!.!Ys!"
- if exist D:\基因合成\!today!\!mls! (move /y "!dvn!" "D:\基因合成\!today!\!mls!" >nul) else (
- md "D:\基因合成\!today!"
- md "D:\基因合成\!today!\!mls!"
- move /y "!dvn!" "D:\基因合成\!today!\!mls!" >nul
- )
- )
- )
- )
- exit
复制代码
|