Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2023, 06:54 AM
kilroyscarnival kilroyscarnival is offline Power Query to get a list of folders (not files) in a location? Windows 10 Power Query to get a list of folders (not files) in a location? Office 2021
Expert
Power Query to get a list of folders (not files) in a location?
 
Join Date: May 2019
Posts: 361
kilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nice
Default

Ah, OK, I didn't realize that if it would work in Power BI it would also work in Excel.

I did open your workbook and change the directory. It does give me a nifty listing of just the main project folders on the drive. My wrinkle is that I actually need the subfolders for invoices in each of the project folders. I am able to do that in Power Query, except for the few Invoices files that don't yet have invoices in them. I'm also able to add a column that trims the long folder just down to the project number, which gives me exactly what I need except for those few empty ones. I have tinkered around with the setup you shared, and I can only get it to list the main folders on the drive.



What I do to get the subfolders is get a list of everything, then filter for where the folder path ends in "Invoices", then filter to uniques. Then I duplicate the folder path column and trim to just the project number, giving me the XLOOKUP info that I need to do the "auto-filing" VBA that Paul helped me figure out here (https://www.msofficeforums.com/excel...using-vba.html)

If I'm missing something and there's a way to get into subfolders, I'll keep trying.

Thanks!

Ann
Reply With Quote
  #2  
Old 02-20-2023, 08:43 AM
p45cal's Avatar
p45cal p45cal is offline Power Query to get a list of folders (not files) in a location? Windows 10 Power Query to get a list of folders (not files) in a location? Office 2019
Expert
 
Join Date: Apr 2014
Posts: 956
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Quote:
Originally Posted by kilroyscarnival View Post
My wrinkle is that I actually need the subfolders for invoices in each of the project folders. I am able to do that in Power Query, except for the few Invoices files that don't yet have invoices in them.
<snip>
I have tinkered around with the setup you shared, and I can only get it to list the main folders on the drive.
If you've done (or started) this with a powershell command, what was the command, because command you've shown only returns the top level of folders?
Are we talking only one level down of subfolders?


Otherwise I'll have an explore in the coming days.
Reply With Quote
  #3  
Old 02-20-2023, 02:40 PM
kilroyscarnival kilroyscarnival is offline Power Query to get a list of folders (not files) in a location? Windows 10 Power Query to get a list of folders (not files) in a location? Office 2021
Expert
Power Query to get a list of folders (not files) in a location?
 
Join Date: May 2019
Posts: 361
kilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nice
Default

Quote:
Originally Posted by p45cal View Post
If you've done (or started) this with a powershell command, what was the command, because command you've shown only returns the top level of folders?
Are we talking only one level down of subfolders?


Otherwise I'll have an explore in the coming days.
Yes, for the most part they are usually just one level down. It'd be like \\Projects\\J1234G State Road 567 at Pine Street Intersection\Invoices\

You're right, I think I just grabbed the wrong Powershell command line that I keep in Outlook Notes. That's the one I used to get the names of all the PDFs of the invoices, which I have changed to doing by PQ. The Powershell command that yields literally everything in the main folder (recursive) is:
Code:
dir -n -r > dirlist.txt
And that yields a lot of rows of data, which I then filter in Excel for anything that ends in "Invoice" and end up concatenating the rest of the file path in.

I suppose the other thing I could do is search out the few ...\Invoices\ subfolders that are empty and place a small dummy file in them?

I think I'm like 90% there, so I'm not that worried about it.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel power query help ganesang Excel Programming 0 09-20-2021 01:50 AM
Browse, search and copy files from one location to another based on the list given in excel sheet us nmkhan3010 Excel Programming 2 09-07-2020 10:27 AM
Do I need a power query for this one? shabbaranks Excel 5 04-10-2019 03:29 AM
Query and Power Query not working Excel 2016 bl10 Excel 0 07-22-2016 06:25 PM
list folders and files using .vbs file josianne Excel Programming 3 08-18-2014 03:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft