+ Reply to Thread
Results 1 to 3 of 3

Files and files sizes in directory

Hybrid View

paularthur90 Files and files sizes in... 07-30-2015, 03:59 PM
xladept Re: Files and files sizes in... 07-30-2015, 04:14 PM
mc84excel Re: Files and files sizes in... 07-30-2015, 07:23 PM
  1. #1
    Registered User
    Join Date
    10-16-2014
    Location
    Manchester
    MS-Off Ver
    2010
    Posts
    26

    Talking Files and files sizes in directory

    Hi,

    I have been searching the internet high and low and still cannot fine anything directly related to what I need.

    I need a macro to output a list of files that are contained in a directory. I also need to output next to that list either the size of the file in KB or the length of the WAV files that are in it. I ask for either one or the two as I can roughly estimate that 2kb in 1 second of recording.

    Could someone please help me?

    Thanks,
    Paul

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Files and files sizes in directory

    Here's some code I had on hand - see if it suits your purpose (it may need some tweaking):

    Sub Runnit()                    'Run the Directory
    Dim S As String, P As String, U As String, i As Integer: i = 1
    
    P = ActiveWorkbook.Path         'or the directory to run
    
    P = P & "\": U = Dir(P): S = P & U: i = i + 1
    
    ThisWorkbook.Sheets("Sheet1").Activate  'or wherever you want the list
    
    NextBook:
    If InStr(1, S, ".xls") Then
    Cells(i, 1) = U: Cells(i, 2) = FileLen(P & U)
    Else:
    i = i - 1: GoTo GetNextBook: End If
    
    GetNextBook: i = i + 1
    'If i > 50 Then Exit Sub             'Failsafe
    On Error GoTo EndSub
    U = Dir()
    GoTo NextBook
    
    EndSub: End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Files and files sizes in directory

    I think I have a VBS for this somewhere. If I find it, I'll upload it.

    Another option - but more involved - see my thread here for a project for returning lists of files/folders http://www.excelforum.com/excel-prog...stage-3-a.html You could cannabilise code from this and use FileLen on each file
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 11-19-2013, 04:11 PM
  2. Moving Files from one directory structure to another directory
    By harddd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2013, 02:39 PM
  3. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  4. Replies: 0
    Last Post: 03-13-2013, 09:08 PM
  5. Macro to Move files from one directory to other directory
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2013, 07:21 AM
  6. Reading in the files in a directory into an array, directory chosen by user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2011, 12:52 PM
  7. Delete all files in directory, msgbox list files before delete.
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2010, 09:28 PM
  8. Reducing files sizes... are macros the solution
    By ste_mulv in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2009, 04:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1