Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 4708|回复: 5

如何批量整理文件内容

[复制链接]
发表于 2019-10-24 22:07 | 显示全部楼层 |阅读模式
2学分
,如何批量将文件归类,做到如上压缩文件中的形式,有何快捷方法,求解

批量文件归类实例.zip

907.79 KB, 下载次数: 16

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2019-10-25 10:44 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2019-10-25 11:02 | 显示全部楼层
影子123 发表于 2019-10-25 10:44
图片就只有三类吗?

可能会有添加,目前只需要这三类
回复

使用道具 举报

发表于 2019-10-25 16:24 | 显示全部楼层
set fso=createobject("scripting.filesystemobject")
Set regEx = CreateObject ("VBScript.RegExp")
    regEx.IgnoreCase = True  
    regEx.Global = True  

filepath=fso.GetFolder(".").Path
For Each subFolder In fso.GetFolder(filepath).SubFolders
    For Each file In fso.GetFolder(subFolder.path).files
        regEx.Pattern = ".+\\|[^\\\u4e00-\u9fa5]+$"
        if regEx.test(file) then
           st=regEx.Replace(file,"")
           if len(st)>0 then
              st=subFolder.path & "\" & regEx.Replace(file,"")
              If not fso.folderExists(st) Then
                 fso.Createfolder(st)
              end if
           fso.movefile file , st & "\"
           end if
        end if
    next
Next


Set regEx = Nothing
Set fso = Nothing
1571991413(1).jpg

自动分类.rar

1.01 KB, 下载次数: 3

回复

使用道具 举报

 楼主| 发表于 2019-10-26 20:30 | 显示全部楼层
可以不将草图归类到文件夹吗?其他的归类,草图照片这个不用放入文件夹中
回复

使用道具 举报

发表于 2019-11-6 17:39 | 显示全部楼层
794905425 发表于 2019-10-26 20:30
可以不将草图归类到文件夹吗?其他的归类,草图照片这个不用放入文件夹中

if len(st)>0 then 改成 if len(st)>0 and st<> "草图照片" then
-----------------------------------------------------------------------------------------------------
set fso=createobject("scripting.filesystemobject")
Set regEx = CreateObject ("VBScript.RegExp")
    regEx.IgnoreCase = True  
    regEx.Global = True  

filepath=fso.GetFolder(".").Path
For Each subFolder In fso.GetFolder(filepath).SubFolders
    For Each file In fso.GetFolder(subFolder.path).files
        regEx.Pattern = ".+\\|[^\\\u4e00-\u9fa5]+$"
        if regEx.test(file) then
           st=regEx.Replace(file,"")
           if len(st)>0 and st<> "草图照片" then
              st=subFolder.path & "\" & regEx.Replace(file,"")
              If not fso.folderExists(st) Then
                 fso.Createfolder(st)
              end if
           fso.movefile file , st & "\"
           end if
        end if
    next
Next


Set regEx = Nothing
Set fso = Nothing
msgbox "运行完成"

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-23 23:50 , Processed in 0.352432 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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