Copy-PnpFile - Copies containing folders of files. #296
Replies: 7 comments 1 reply
-
Hi @Bhushan12986, I had no issue on my side copying just the files (no folders) when using this approach (change SitePnP1 and SitePnP2 to your sites):
|
Beta Was this translation helpful? Give feedback.
-
We have exported source library details to a CSV file and we are reading data from it only as we need to update some metadata/properties which is also part of the same CSV file of copied files. We are using Path and Name fields' combination as source document URL as below, still containing folders are getting copied to the target document library.
|
Beta Was this translation helpful? Give feedback.
-
@Bhushan12986 - Are you explicitly giving each file name in your csv file? If not, please use the |
Beta Was this translation helpful? Give feedback.
-
Hi @veronicageek, Yes, we are reading each file name explicitly from CSV file. Path and Name are columns from CSV itself for file path and name respectively. CSV contains only details of the files, it does not contain any row of folder details, we have removed folder rows from it. We also tried with below code but output is same, it is copying containing folders too.
Also, is it possible to return copied document using Copy-PnPFile to get the ID of the new copied document in order to update metadata/properties? |
Beta Was this translation helpful? Give feedback.
-
Moving into a discussion as this is more related to a script and not an issue with the cmdlet. |
Beta Was this translation helpful? Give feedback.
-
@Bhushan12986 - Can you post an example of your CSV file with dummy data? And also try on a subset with the condition using |
Beta Was this translation helpful? Give feedback.
-
From my testing this is a bug with this version of pnp powershell that is fixed in the current version of PnP.Powershell. To work around it you simply need to add a slash ( + "/") to the end of the SourceUrl field. |
Beta Was this translation helpful? Give feedback.
-
Reporting an Issue or Missing Feature
We have a requirement of copying files from one document library to another document library with different site collections. However, in source document library, we have files inside nested folders, but we want to copy all files not folders to the target document library.
When we are trying to copy files, containing folders are also getting copied to target library.
Expected behavior
Only files should get copied to the target library.
Actual behavior
When we are trying to copy files, containing folders are also getting copied to target library.
Steps to reproduce behaviour
Copy-PnPFile -SourceUrl "Source Document URL" -TargetUrl "Target Library URL" -Force;
What is the version of the Cmdlet module you are running?
Which operating system/environment are you running PnP PowerShell on?
Beta Was this translation helpful? Give feedback.
All reactions