+ Reply to Thread
Results 1 to 4 of 4

Macro to strip out items in text file and paste into columns

  1. #1
    Registered User
    Join Date
    07-21-2012
    Location
    London, englan
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro to strip out items in text file and paste into columns

    Hello everyone;

    I am looking for a simple macro to extract information from a text file.

    I am creating the text file using the following command in command prompt: dir /S *.asf > VideoIndex.txt. This bypasses having to search hundreds of folders and manually extract the files names as it was being done previously.


    Within this text file is the following:
    ------------------------------------------------------------------------------------------------

    Volume in drive I is Seagate Backup Plus Drive
    Volume Serial Number is 061B-9493

    Directory of I:\VisualWorks\Projects\PROJECT\NE-LCP_SINS_2014_LC-SB-034_0001\DATA_20140901191709109

    09/01/2014 05:18 PM 470,254,325 20140901191709109@DVR2_Ch1.asf
    09/01/2014 05:18 PM 470,462,325 20140901191709500@DVR2_Ch2.asf
    09/01/2014 05:18 PM 470,422,331 20140901191709656@DVR2_Ch3.asf
    3 File(s) 1,411,138,981 bytes

    Directory of I:\VisualWorks\Projects\PROJECT\NE-LCP_SINS_2014_LC-SB-034_0001\DATA_20140901194709813

    09/01/2014 05:48 PM 470,390,325 20140901194709813@DVR2_Ch1.asf
    09/01/2014 05:48 PM 470,478,331 20140901194710047@DVR2_Ch2.asf
    09/01/2014 05:48 PM 470,414,331 20140901194710203@DVR2_Ch3.asf
    3 File(s) 1,411,282,987 bytes

    Total Files Listed:
    445 File(s) 165,834,604,455 bytes
    0 Dir(s) 1,850,604,470,272 bytes free

    ------------------------------------------------------------------------------------------------

    I need to extract the the Video File Name, Project Task ID, Date, From Time, To Time and put that into a Excel sheet as shown below.

    Please Login or Register  to view this content.
    The Video File name is all the .asf extensions
    The Project Task ID is contained in the Directory name
    The Date is taken from the .asf file name ex. 20140901191709109@DVR2_Ch1.asf, gives me a date of > 20140901

    The Times are a bit weird and are extracted from the .asf file name. In this particular case we are taking the UTC time in the file name and subtracting -2.5 hours to get the "From Time", then taking the file name and subtracting -2.0 hours to obtain the "To Time". Each video file should be 30 minutes.
    ex. 20140901191709109@DVR2_Ch1.asf, gives a From Time of 16:47:09 and a To time of 17:17:09.


    I have a spreadsheet that does this but it uses a complex array of filtering, cell referencing and other formula to derive what I want. It works for me but I am the only one who knows how to use it I would like to make others peoples lives easier if I can and automate this better.

    Any help is greatly appreciated.
    Attached Files Attached Files
    Last edited by reesjordan; 09-10-2014 at 08:20 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to strip out items in text file and paste into columns

    Hi reesjordan

    Will you be so kind as to post your solution?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Macro to strip out items in text file and paste into columns

    Hi reesjordan,

    Try the attached file. Code excerpts follow.

    Lewis

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to strip out items in text file and paste into columns

    @ reesjordan
    @ LJMetzger

    I had also developed a solution but as I saw the Thread was marked SOLVED I didn't post it...the Code is in the attached.
    Attached Files Attached Files

+ 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. macro to copy used range and paste in the body tag of a html file/text file
    By amethystfeb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2014, 08:34 PM
  2. [SOLVED] Modify macro to repeat once, accept a different file type and paste into different columns
    By vegetable in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-07-2013, 12:46 PM
  3. Replies: 13
    Last Post: 11-29-2012, 08:25 PM
  4. Strip Excess Semi-Colon from Text File
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2011, 01:30 PM
  5. [SOLVED] Strip out text copy and paste?
    By Mark Y via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 12-07-2005, 09:20 AM

Tags for this Thread

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