Sub kkk()
'将文件夹和文件名读取到工作表中
Cells.Clear
myrow = 1
Set fileopea =
CreateObject("scripting.filesystemobject")
Set objFolder =
fileopea.GetFolder("G:\excel")
For Each myfolder In
objFolder.SubFolders
For Each
myfile In myfolder.Files
Cells(myrow, 1) =
myfolder
Cells(myrow, 2) = Mid(myfile,
InStrRev(myfile, "\") + 1, Len(myfile))
myrow = myrow +
1
Next
Next
End Sub
Sub hhh()
'列出文件夹下的所有XLS文件,不用FSO
Cells.Clear
myrow = 1
aa = Dir("G:\excel\*.xls")
Do While aa <> ""
Cells(myrow, 1) = aa
aa =
Dir()
myrow =
myrow + 1
Loop
End Sub
Sub ppp()
'将某文件夹下的子文件夹下的文件读出(最多两层),并添加文件大小信息
Cells.Clear
mypath = "G:\电子书\史书\明实录清实录"
Dim fs, f, f1, s, sf
Dim myfile
Dim myrow%
Dim filesize$
myrow = 1
filesize = ""
Cells.Clear
Set fs =
CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(mypath)
Set sf = f.SubFolders
MsgBox sf.Count
For Each f1 In sf
Set aaa =
f1.Files
For Each
myfile In aaa
Cells(myrow, 1) =
myfile.Name
If myfile.Size / 1024 / 1024
< 1 Then
filesize = "0" & CStr(Round(myfile.Size /
1024 / 1024, 2)) & "MB"
Else
filesize = CStr(Round(myfile.Size / 1024 / 1024,
2)) & "MB"
End If
Cells(myrow, 2) =
filesize
myrow = myrow +
1
Next
myfile
Next
End Sub
Sub hhh()
'批量修改目标文件夹中的文件名
myrow = 1
aa = Dir("d:\一休\*.flv")
cc = "d:\一休\"
Do While aa <> ""
dd = cc
& aa
bb = cc
& Left(aa, 7) & Right(aa, 4)
Name dd As
bb
aa =
Dir()
Loop
End Sub
Sub kkk()
Dim i%
Dim mulu$
mulu = "d:\dili\"
For i = 1 To 109
Name mulu
& Cells(i, 2) As mulu & Cells(i, 3)
Next i
End Sub
加载中,请稍候......