仅从文件夹复制 Windows 文件大小

发布于 2024-10-18 16:20:58 字数 39 浏览 1 评论 0原文

我想将特定文件夹中每个文件的文件大小写入Excel。我该怎么做?

I would like to write the file size of each file in a particular folder to Excel. How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

荒人说梦 2024-10-25 16:20:58

您可以使用 FileSystemObject 对象来处理文件、文件夹和文本流:

''Reference: Windows Script Host Object Model

Dim fs As New FileSystemObject
Dim fldr As Folder
Dim f As File
Dim i As Integer

Set fldr = fs.GetFolder("C:\docs\")

With ActiveWorkbook.Sheets("Sheet3")
    i = 1
    For Each f In fldr.Files
        .Cells(i, 1) = f.Name
        .Cells(i, 2) = f.Size
        i = i + 1
    Next
End With

You can use the FileSystemObject object to work with files, folders and textstreams:

''Reference: Windows Script Host Object Model

Dim fs As New FileSystemObject
Dim fldr As Folder
Dim f As File
Dim i As Integer

Set fldr = fs.GetFolder("C:\docs\")

With ActiveWorkbook.Sheets("Sheet3")
    i = 1
    For Each f In fldr.Files
        .Cells(i, 1) = f.Name
        .Cells(i, 2) = f.Size
        i = i + 1
    Next
End With
彩虹直至黑白 2024-10-25 16:20:58

由于您没有提到任何有关编程的内容,我认为这属于 SuperUser,但您只需选择所有文件,右键单击,选择属性,然后复制大小。

As you haven't mentioned anything about programming, I think this belongs on SuperUser, but you just need to select all the files, right-click, select Properties, and copy the Size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文