Error when importing from folders

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I have the following code that simple pulls in the attributes of the files within the folders. I'm doing this so I can read a large number of folders and return their sizes and file sizes etc. The problem I have is that people have saved files with very long file names and so when Power Query tries to read them it returns an error for the particular file. That's not a problem as an Error Query is created and I can correct the files.

My problem is that when analysing a lot of folders it stops at a file that causes an error. I'm at a loss as to how to solve it, but was thinking some kind of IF statement.

Any ideas would be appreciated. I have only just started using Power Query, having moved from using solely VBA.


let
Source = Folder.Files("C:\\MyDocs\Folder1\Folder2"),
#"Expanded Attributes" = Table.ExpandRecordColumn(Source, "Attributes", {"Kind", "Size"}, {"Attributes.Kind", "Attributes.Size"})
in
#"Expanded Attributes"
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
try this
Rich (BB code):
let
   Source = Folder.Files("C:\\MyDocs\Folder1\Folder2"),
   #"Expanded Attributes" = try Table.ExpandRecordColumn(Source, "Attributes", {"Kind", "Size"}, {"Attributes.Kind", "Attributes.Size"}) otherwise "check"
in
   #"Expanded Attributes"

and use code tags [CODE] you code here [/CODE]
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top