Home > Software engineering >  Tip 800 a400c, can help us see what is wrong? thank you
Tip 800 a400c, can help us see what is wrong? thank you

Time:11-06

The Set of fso=createobject (" scripting. Filesystemobject ")
Curdir=fso. Getparentfoldername (wscript. Scriptfullname)

Fhtdir=fso. Buildpath (curdir, "FHT")
Fctdir=fso. Buildpath (curdir, "FWZP")
Dfcdir=fso. Buildpath (curdir, "tea mountain village")

The Set reg=createobject (" vbscript. Regexp ")
Reg. Global=False
Reg. The ignorecase=True
Reg. Multiline=False

Movefiles fhtdir dfcdir, "(\ w {and}) (\ w {5}) _FHT", "household property figure in"
Movefiles fctdir dfcdir, "(\ w {and}) (\ w {5}) _FWZP", "housing picture
"
Msgbox "done!"

Sub MoveFiles (ByVal srcdir, ByVal destdir, ByVal strpattern, ByVal strsubdir)
Reg. The pattern=strpattern
For Each objfile In fso. Getfolder (srcdir) files
Strbasename=fso. Getbasename (objfile. Name)
The (strbasename) Then the If reg
The Set objmatch=reg. The execute (strbasename) (0)
Part1=objmatch. Submatches (0)
Part2=objmatch. Submatches (1)

The dir1-name=getmatchdir (destdir, part1)
If the dir1-name & lt;> "" Then
Dir2=getmatchdir (dir1-name, part1 & amp; Part2)
If dir2 & lt;> "" Then
Dir3=fso. Buildpath (dir2, strsubdir)
The Else
Dir3=fso. Buildpath (dir1-name strsubdir)
End the If
If fso. Folderexists (dir3) Then
Objfile. Move fso. Buildpath (dir3 objfile. Name)
End the If
End the If
End the If
Next
End Sub

'get to specify the name at the beginning of a folder path;
The Function GetMatchDir (ByVal pntdir, ByVal strbase)
For Each objdir In fso. Getfolder (pntdir). Subfolders
If Len (objdir. Name) & gt;=Len (strbase) Then
If StrComp (Left (objdir. Name, Len (strbase)), strbase, 1)=0 Then
Getmatchdir=objdir. Path
The Exit Function
End the If
End the If
Next
Getmatchdir=""
End the Function
  •  Tags:  
  • VBA
  • Related