Dim FolderPaths,Fso,Gfolder,Filec,Collection
Dim GFileName
'目标文件夹地址
FolderPaths = "C:\Users\Administrator\Desktop\新建文件夹 (3)"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Gfolder = Fso.GetFolder(FolderPaths)
Set Filec = Gfolder.Files
For Each Collection in Filec
Get_fileName Collection.name,Collection.path
Next
Function Get_fileName(files,path)
Dim Str1,Str2,FileName
Str1 = Len(files) - 4
Str2 = Len(files) - 5
Str2 = Left(files,Str2)
Abnormal_Situation Left(files,Str1),files,path,Str2
End Function
Function Abnormal_Situation(fileName,Filesname,path,fileNameX)
Dim Name,Str,CreateF
If Right(fileName,1) = "." Then
If Fso.FolderExists(FolderPaths + "\" + fileNameX) Then
Fso.CopyFile path,FolderPaths + "\" + fileNameX + "\"
Fso.DeleteFile path
Else
Set CreateF = Fso.CreateFolder(FolderPaths + "\" + fileNameX)
Fso.CopyFile path,FolderPaths + "\" + fileNameX + "\"
Fso.DeleteFile path
End If
Else
Name = fileName
If Fso.FolderExists(FolderPaths + "\" + Name) Then
Fso.CopyFile path,FolderPaths + "\" + Name + "\"
Fso.DeleteFile path
Else
Set CreateF = Fso.CreateFolder(FolderPaths + "\" + Name)
Fso.CopyFile path,FolderPaths + "\" + Name + "\"
Fso.DeleteFile path
End If
End If
End Function
保存为.vbs文件,修改代码中对应的目标文件夹地址运行即可
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。