SOLVED

Copy File - variable folder name as Destination Folder

%3CLINGO-SUB%20id%3D%22lingo-sub-1651268%22%20slang%3D%22en-US%22%3EUsing%20Copy%20File%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1651268%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20flow%20to%20copy%20a%20file%20from%20a%20folder%20in%20a%20Document%20Library%20(called%20Master)%20to%20a%20folder%20with%20the%20same%20name%20in%20a%20different%20Document%20Library%20(called%20Draft)%20and%20if%20possible%20using%20part%20of%20the%20Folder%20Name%20as%20a%20variable%20-%20%2FMaster%2F%3CSTRONG%3E01%20Folder%20A%20-%26nbsp%3B%3C%2FSTRONG%3Eis%20this%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20flow%20is%20as%20follows%20so%20far%20and%20works%20until%20the%20last%20Copy%20File%20step%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EFor%20a%20selected%20file%3C%2FSTRONG%3E%20(Site%20Address%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2C%3C%2FA%3E%26nbsp%3BLibrary%20Name%3A%20Master)%3C%2FP%3E%3CP%3E%3CSTRONG%3EGet%20file%20properties%3C%2FSTRONG%3E%20(Site%20Address%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2C%3C%2FA%3E%26nbsp%3BLibrary%20Name%3A%20Master%2C%20Id%3A%20ID)%3C%2FP%3E%3CP%3E%3CSTRONG%3EInitialize%20variable%3C%2FSTRONG%3E%20(Name%3A%20FileID%2C%20Type%3A%20String%2C%20Value%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2FFullPath%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2FFullPath%3C%2FA%3E)%3C%2FP%3E%3CP%3E%3CSTRONG%3EGet%20file%20metadata%20using%20path%3C%2FSTRONG%3E%20(Site%20Address%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2C%3C%2FA%3E%26nbsp%3BFile%20Path%3A%20FileID)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E...and%20here's%20where%20I%20have%20trouble%20with%20the%20Destination%20Site%20Address%20and%20Folder%3C%2FP%3E%3CP%3E%3CSTRONG%3ECopy%20file%3C%2FSTRONG%3E%20(Current%20Site%20Address%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2C%3C%2FA%3E%26nbsp%3BFile%20to%20Copy%3A%20FileID%2C%20Destination%20Site%20Address%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2C%3C%2FA%3E%26nbsp%3B%3CEM%3E%3CSTRONG%3EDestination%20Folder%3A%20%2FDrafts%2FXXX%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20I%20can%20use%20an%20expression%20to%20get%20part%20of%20the%20Folder%20Path%20from%20previous%20steps%20to%20fill%20in.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20if%20I%20was%20copying%20a%20file%20from%20Folder%20Path%3A%20Master%2F%3CSTRONG%3E01%20Folder%20A%3C%2FSTRONG%3E%2F%2C%20is%20there%20an%20expression%20I%20can%20use%20to%20extract%20just%20the%20%3CSTRONG%3E01%20Folder%20A%3C%2FSTRONG%3E%20part%20of%20the%20string%20to%20fill%20in%20the%20Destination%20Folder%20so%20when%20it%20ran%2C%20the%20Destination%20Folder%20would%20essentially%20show%20as%20%2FDrafts%2F%25variable%25%20and%20result%20in%20%2FDrafts%2F01%20Folder%20A%20or%20if%20I%20ran%20the%20flow%20from%20Master%2F02%20Folder%20B%2C%20the%20Destination%20Folder%20would%20know%20the%20path%20is%20%2FDrafts%2F02%20Folder%20B.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1651268%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerApps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1651513%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20File%20-%20variable%20folder%20name%20as%20Destination%20Folder%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1651513%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20just%20tried%20to%20use%20Get%20Folder%20Metadata%20step%20and%20I%20can%20see%20the%20correct%20values%20in%20Name%20and%20DisplayName%20but%20when%20I%20try%20to%20use%20this%20as%20a%20variable%20in%20the%20Copy%20File%20step%20as%20Destination%20Site%20address%3A%20%3CA%20href%3D%22https%3A%2F%2Fcontoso.com%2FSite%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.com%2FSite%2C%3C%2FA%3E%26nbsp%3BDestination%20Folder%3A%20%2FDrafts%2FDisplayName%20it%20throws%20a%26nbsp%3B%3CEM%3EFailed%20to%20verify%20the%20existence%20of%20source%20object%20at%3C%2FEM%3E%20error.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I am trying to create a flow to copy a file from a folder in a Document Library (called Master) to a folder with the same name in a different Document Library (called Draft) and if possible using part of the Folder Name as a variable - /Master/01 Folder A - is this possible?

 

My flow is as follows so far and works until the last Copy File step:

For a selected file (Site Address: https://contoso.com/Site, Library Name: Master)

Get file properties (Site Address: https://contoso.com/Site, Library Name: Master, Id: ID)

Initialize variable (Name: FileID, Type: String, Value: https://contoso.com/Site/FullPath)

Get file metadata using path (Site Address: https://contoso.com/Site, File Path: FileID)

 

...and here's where I have trouble with the Destination Site Address and Folder

Copy file (Current Site Address: https://contoso.com/Site, File to Copy: FileID, Destination Site Address: https://contoso.com/Site, Destination Folder: /Drafts/XXX

 

Is there a way I can use an expression to get part of the Folder Path from previous steps to fill in.

 

For example, if I was copying a file from Folder Path: Master/01 Folder A/, is there an expression I can use to extract just the 01 Folder A part of the string to fill in the Destination Folder so when it ran, the Destination Folder would essentially show as /Drafts/%variable% and result in /Drafts/01 Folder A or if I ran the flow from Master/02 Folder B, the Destination Folder would know the path is /Drafts/02 Folder B.

 

2 Replies
Highlighted

I've just tried to use Get Folder Metadata step and I can see the correct values in Name and DisplayName but when I try to use this as a variable in the Copy File step as Destination Site address: https://contoso.com/Site, Destination Folder: /Drafts/DisplayName it throws a Failed to verify the existence of source object at error.

Highlighted
Best Response confirmed by albertstain (Occasional Contributor)
Solution

Solved after some more work!

 

Created a Get Folder Metadata step

Created an Initialize Variable called FolderID, type: String, Value: DisplayName (from Get folder Metadata)

 

The last Copy file:

Current Site Address: https://contoso.com/Site

File to copy: Identifier (from Get Item)

Destination Site Address: https://contoso.com/Site

Destination Folder: /Drafts/FolderID (variable)

 

Horray!