cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

Import Folder long path

Hi,

 

I am trying to use Import - Folder to pull a list of files in a folder/sub folders so I can do some analysis of the file types and where they are stored.  I'm running into an issue where there are stupid long file paths:

 

DataFormat.Error: The file name '\\server\share\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\*' is longer than the system-defined maximum length.

 

I tried using "replace errors" in the query editor but that didn't work.

 

Anyone have any ideas?

 

Dan

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Import Folder long path

Hi @robofski ,

 

1. Create a parameter in Power query make the parameter is \\server\share\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder.

 

2. Edit the M code in your Advanced editor to replace the file pate to parameter.

 

let
    Source = Folder.Files(""&Parameter1),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from New folder", each #"Transform File from New folder"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File from New folder"}),
    #"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from New folder", Table.ColumnNames(#"Transform File from New folder"(#"Sample File"))),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Date", type date}, {"cat", type text}, {"Sales", Int64.Type}})
in
    #"Changed Type"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Import Folder long path

Hi @robofski ,

 

1. Create a parameter in Power query make the parameter is \\server\share\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder.

 

2. Edit the M code in your Advanced editor to replace the file pate to parameter.

 

let
    Source = Folder.Files(""&Parameter1),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from New folder", each #"Transform File from New folder"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File from New folder"}),
    #"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from New folder", Table.ColumnNames(#"Transform File from New folder"(#"Sample File"))),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Date", type date}, {"cat", type text}, {"Sales", Int64.Type}})
in
    #"Changed Type"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: Import Folder long path

I have the same problem but sadly this solution does not work for me. 

it´s like the small link is always the same

 \\server\share\folder\another folder\another folder 

and than comes long link with different folders

\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder.....

 

so even with Parameter its too long.

need Halp

 

I would like to combine Excel files from different folders as a one list. 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors