找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 31744|回复: 4

[文件操作] [已解决]BAT批处理如何按要求移动文件?

[复制链接]
发表于 2014-4-8 11:04:09 | 显示全部楼层 |阅读模式
本帖最后由 DDDYJQ1 于 2014-4-8 13:47 编辑

文件夹下有上千个.HTM文件,文件名如下
文件名                             要创建的文件夹名
content.asp@uni=E401.html         E4
content.asp@uni=2F73.html         2F
content.asp@uni=E402.html         E4
content.asp@uni=052611.html       052
content.asp@uni=052543.html       052
content.asp@uni=052B26.html       052
content.asp@uni=052550.html       052
content.asp@uni=052C11.html       052
content.asp@uni=052609.html       052
content.asp@uni=052610.html       052
content.asp@uni=052541.html       052
content.asp@uni=2F879.html        2F
content.asp@uni=052612.html       052
content.asp@uni=052615.html       052
content.asp@uni=21482.html        214
content.asp@uni=29B5A.html        29
content.asp@uni=29B5B.html        29
content.asp@uni=29B5C.html        29
content.asp@uni=29B5D.html        29
content.asp@uni=180500.html       180
想按等号后的部分,创建文件夹,有四个字符的,创建文件夹为前两个字符,有五个字符的,也创建文件夹名为前两个字符,有六个文件名的,创建文件夹名为前三个字符,并移入新创建的文件夹中。不知表达是否清楚,先谢了,

评分

参与人数 1PB +2 收起 理由
Batcher + 2 感谢给帖子标题标注[已解决]字样

查看全部评分

发表于 2014-4-8 11:37:34 | 显示全部楼层
有6个以上字符怎么处理 比如8个字符
发表于 2014-4-8 11:48:27 | 显示全部楼层
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in ('dir /b /a-d *.html') do (
  3.     for /f "tokens=2delims==" %%j in ("%%~ni") do (
  4.         set str=%%j
  5.         if "!str:~5!" == "" (
  6.             md "!str:~,2!" 2>nul
  7.         ) else md "!str:~,3!" 2>nul
  8.     )
  9. )
  10. pause
复制代码
发表于 2014-4-8 11:50:10 | 显示全部楼层

  1. @echo off&setlocal EnableDelayedExpansion
  2. (for %%a in (*.html) do (
  3.     for /f "tokens=1* delims==" %%b in ("%%~na") do (
  4.         set "str=%%c"
  5.         if defined str if "!str:~5!"=="" (set "str=!str:~,2!")else set "str=!str:~,3!"
  6.     )
  7.     md "!str!"
  8.     move "%%a" "!str!"
  9. ))2>nul
复制代码

评分

参与人数 1技术 +1 收起 理由
Batcher + 1 乐于助人

查看全部评分

 楼主| 发表于 2014-4-8 13:47:20 | 显示全部楼层
谢谢各位,最多只有六个字行,3楼的只建立文件夹,4楼的可以,谢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-21 07:44 , Processed in 0.031228 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表