Excel精英培训网

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

[已解决]难度可能比较大 -工作中实际案例,照片重命名问题

[复制链接]
发表于 2022-8-23 15:11 | 显示全部楼层 |阅读模式
本帖最后由 sparkguo 于 2022-8-23 15:19 编辑
工作中遇到的实际问题,证书报名 上传附件操作很麻烦,尝试找找各位老师,看看有没有可能解决
辛苦了啊
详见附件
最佳答案
2022-8-24 20:55
Sub tt()
    On Error Resume Next
    Dim D1 As Object
    Dim D2 As Object
    Dim MyFile As Object
    Dim F, Fd
    Dim Ar, Br, R%, K%, StrPath$
    Set D1 = CreateObject("scripting.dictionary")
    Set D2 = CreateObject("scripting.dictionary")
    Set MyFile = CreateObject("Scripting.FileSystemObject")
    StrPath = ThisWorkbook.Path & "\原始照片"
    Ar = Sheets("数据区域").[a1].CurrentRegion
    For R = 2 To UBound(Ar)
        D1(Ar(R, 3)) = Ar(R, 7)
        D2(Ar(R, 3)) = Ar(R, 5)
    Next R
    Br = Sheets("操作区域").[b2].CurrentRegion
    For Each Fd In MyFile.getfolder(StrPath).subfolders
        For Each F In Fd.Files
            For R = 5 To UBound(Br)
                If F.Name Like Br(R, 1) & "*头*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "t.jpg"
                ElseIf F.Name Like Br(R, 1) & "*学*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "x.jpg"
                ElseIf F.Name Like Br(R, 1) & "*工作年限*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "g.jpg"
                ElseIf F.Name Like Br(R, 1) & "*身份证1*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "z.jpg"
                ElseIf F.Name Like Br(R, 1) & "*身份证2*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "f.jpg"
                ElseIf F.Name Like Br(R, 1) & "*报名*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "b" & D2(Br(R, 1)) & ".jpg"
                End If
            Next R
        Next F
    Next Fd
    Set MyFile = Nothing
End Sub
12.jpg

新建文件夹.rar

771.02 KB, 下载次数: 9

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2022-8-24 20:55 | 显示全部楼层    本楼为最佳答案   
Sub tt()
    On Error Resume Next
    Dim D1 As Object
    Dim D2 As Object
    Dim MyFile As Object
    Dim F, Fd
    Dim Ar, Br, R%, K%, StrPath$
    Set D1 = CreateObject("scripting.dictionary")
    Set D2 = CreateObject("scripting.dictionary")
    Set MyFile = CreateObject("Scripting.FileSystemObject")
    StrPath = ThisWorkbook.Path & "\原始照片"
    Ar = Sheets("数据区域").[a1].CurrentRegion
    For R = 2 To UBound(Ar)
        D1(Ar(R, 3)) = Ar(R, 7)
        D2(Ar(R, 3)) = Ar(R, 5)
    Next R
    Br = Sheets("操作区域").[b2].CurrentRegion
    For Each Fd In MyFile.getfolder(StrPath).subfolders
        For Each F In Fd.Files
            For R = 5 To UBound(Br)
                If F.Name Like Br(R, 1) & "*头*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "t.jpg"
                ElseIf F.Name Like Br(R, 1) & "*学*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "x.jpg"
                ElseIf F.Name Like Br(R, 1) & "*工作年限*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "g.jpg"
                ElseIf F.Name Like Br(R, 1) & "*身份证1*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "z.jpg"
                ElseIf F.Name Like Br(R, 1) & "*身份证2*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "f.jpg"
                ElseIf F.Name Like Br(R, 1) & "*报名*" Then
                    Name F.Path As Fd.Path & "\" & D1(Br(R, 1)) & "b" & D2(Br(R, 1)) & ".jpg"
                End If
            Next R
        Next F
    Next Fd
    Set MyFile = Nothing
End Sub

重命名图片(20220824).rar

772.01 KB, 下载次数: 2

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-29 23:14 , Processed in 0.384844 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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