Add file sizes together

kojak43

Active Member
Joined
Feb 23, 2002
Messages
270
I have several files of different sizes. Is it possible to open the folder in Windows Explorer, copy the files, including the sizes, and Paste Special>Text into Excel?

When I select all the files in a folder, it selects the name. When I copy, I am pretty sure it is copying the entire file. I don't want to copy the files, I want to copy the data details.

The folder contains .jpg images, I just want to transfer the file size into Excel, not the actual images.

Thanks for any way to capture this information. BTW, I am using Windows XP and Excel 2003.

k
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
if you just want to insert the filename and size into a sheet try the following, it is set to just include JPEG files, and does not go further than the current folder level you set.

With a bit more code you can traverse down folders and subfolders

This will start in cell A1 and insert filename with size in B1 and move down as more files are found


Sub GetFileSizeInfo()

Dim FSO As Object, f As Object, Path As String
Dim CurrentRow As Range

Path = "E:\256 card"
Set FSO = CreateObject("Scripting.FileSystemObject")

Set CurrentRow = Range("A1")

For Each f In FSO.GetFolder(Path).Files
If f.Type = "JPEG Image" Then
CurrentRow.Value = f.Name
CurrentRow.Offset(0, 1).Value = f.Size
Set CurrentRow = CurrentRow.Offset(1, 0)
End If
Next
End Sub
 
Upvote 0
Thank you both

I am constantly amazed with the talent at this site.

I downloaded the Shell File and it worked great. I'll try the code in a few days.

Thank you very much for the guidance.

k
 
Upvote 0

Forum statistics

Threads
1,213,515
Messages
6,114,080
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top