Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
creyssonbr
New Member

Using regex to extract directory listing information

Hi,


I need to extract the filename and date of modification from prints that I receive.

Is it possbile on to put that info in a table?

I did it manually, but query gets broken when anything there changes.


They look like this:

D:\Temp>dir
 Volume in drive D is HDDX
 Volume Serial Number is XXXX-XXXX

 Directory of D:\Temp

02/28/2021  08:23 PM    <DIR>          .
02/28/2021  08:23 PM    <DIR>          ..
02/28/2021  08:22 PM               193 assistant_installer_20210228202253.log
02/28/2021  08:20 PM                 0 file1 - Copy (2).txt
02/28/2021  08:20 PM                 0 file1 - Copy (3).txt
02/28/2021  08:20 PM                 0 file1 - Copy (4).txt
02/28/2021  08:20 PM                 0 file1 - Copy (5).txt
02/28/2021  08:20 PM                 0 file1 - Copy (6).txt
02/28/2021  08:20 PM                 0 file1 - Copy (7).txt
02/28/2021  08:20 PM                 0 file1 - Copy (8).txt
02/28/2021  08:20 PM                 0 file1 - Copy (9).txt
02/28/2021  08:20 PM                 0 file1.txt
02/28/2021  08:20 PM                 0 file2.txt
02/28/2021  06:40 PM                 0 FXSAPIDebugLogFile.txt
02/28/2021  06:40 PM            50,216 ThrottleStop.sys
              13 File(s)         50,409 bytes
               2 Dir(s)  225,865,232,384 bytes free
3 REPLIES 3
Vera_33
Resident Rockstar
Resident Rockstar

Hi @creyssonbr 

 

You can use Web.Page to wrap regex, however, I don't know how to extract MM/DD/YYY HH:MM AM/PM. Below one is not working...just show Web.Page, you can add a custom column

 

[   fx=(e as text) =>Web.Page(
        "<script>
        var regex = /^\d{2}/\d{2}/\d{4}\s+\d{2}:\d{2}\s+(AM|PM)$/;
        document.write('"&e&"'.match(regex));
        </script>")[Data]{0}[Children]{0}[Children]{1}[Text]{0},
    b = fx( [your Column])][b]

  

If your print in text is all structured, use below ones?

 

Vera_33_0-1614740759802.png

Table.AddColumn(Source, "Custom", each Text.Start([Column1],20)

Table.AddColumn(#"Added Custom", "Custom1", each Text.Middle([Column1],20))
Greg_Deckler
Super User
Super User

@creyssonbr You should be able to use a folder query, that will get a list of source files in the directory. Not sure about the last modificiation date.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks for your reply @Greg_Deckler .

 

I would but I don't have access to that folder.

I only receive a print in txt.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors