Forum Discussion
Unable to use power query to combine files in folder synced from SharePoint due to system file
- Jun 10, 2024
How do I work around this system file issue?
When you query a folder path you get something like:
where the [Attributes] column contains a Record per file. Each Record has a number of Fields, one of them being 'System'. The latter tells you if the file is marked as a System file
To filter out System files you can do:
let Source = Folder.Files("To_Be_Replaced_With_Path_To_Folder"), FilteredOutSystemFiles = Table.SelectRows(Source, each [Attributes]?[System]? <> true) in FilteredOutSystemFiles
similarly with Hidden files (if a file is open when you query a folder its name starts with ~$ and it's marked as Hidden:
to get rid of Hidden files:
let Source = Folder.Files("To_Be_Replaced_With_Path_To_Folder"), FilteredOutHiddenFiles = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true) in FilteredOutHiddenFiles
To filter out System + Hidden files:
let Source = Folder.Files("To_Be_Replaced_With_Path_To_Folder"), FilteredOutSystemAndHiddenFiles = Table.SelectRows(Source, each ([Attributes]?[System]? <> true) and ([Attributes]?[Hidden]? <> true) ) in FilteredOutSystemAndHiddenFiles
How do I work around this system file issue?
When you query a folder path you get something like:
where the [Attributes] column contains a Record per file. Each Record has a number of Fields, one of them being 'System'. The latter tells you if the file is marked as a System file
To filter out System files you can do:
let
Source = Folder.Files("To_Be_Replaced_With_Path_To_Folder"),
FilteredOutSystemFiles = Table.SelectRows(Source, each [Attributes]?[System]? <> true)
in
FilteredOutSystemFiles
similarly with Hidden files (if a file is open when you query a folder its name starts with ~$ and it's marked as Hidden:
to get rid of Hidden files:
let
Source = Folder.Files("To_Be_Replaced_With_Path_To_Folder"),
FilteredOutHiddenFiles = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true)
in
FilteredOutHiddenFiles
To filter out System + Hidden files:
let
Source = Folder.Files("To_Be_Replaced_With_Path_To_Folder"),
FilteredOutSystemAndHiddenFiles = Table.SelectRows(Source, each
([Attributes]?[System]? <> true) and
([Attributes]?[Hidden]? <> true)
)
in
FilteredOutSystemAndHiddenFiles
- Beckie_WhiteJun 10, 2024Copper Contributor
Lorenzo that did it! Thank you! It seems so obvious now.
- LorenzoJun 10, 2024Silver ContributorYou're welcome + glad you could to adapt the sample(s) to your context & Thanks for providing feedback (helps people who Search)