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
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,769
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
 

Watch MrExcel Video

Forum statistics

Threads
1,114,675
Messages
5,549,367
Members
410,911
Latest member
AniEx
Top