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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,799
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
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
 

kojak43

Active Member
Joined
Feb 23, 2002
Messages
270
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,129
Messages
5,857,537
Members
431,884
Latest member
Gcmoore63

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
Top