Move files backwards in a file path

Hello - looking for help to create a workflow that moves all files in folder backwards two folders. - see below for example. I do not want/need the last two folders in this path and want to move the files to the folder with the detail folder name. Any ideas?

@audra.swope

For each file in folder with the source folder as input..inside that use move file activity with currentfile.fullname as input and destination as the location of 2 folder down

Cheers

Hi @audra.swope

you can consider following below approach:

  1. have a source folder path and target folder path(2 folders backward path)
  2. then use “get files” activity to get all files in source path
  3. use for loop to move those files(by using move file activity) to target folder

you can also refer below video on same:

Hope this helps.

You can use the Directory.GetParent expression to get the parent folder. So use it twice to get the parent of the parent.

image

Directory.GetParent(Directory.GetParent(*YourFolder*).ToString).ToString

Hello @audra.swope
Please try using vb code

sourceFolder = “C:\Main\Detail\Temp1\Temp2”

For Each file In Directory.GetFiles(sourceFolder)
grandParent = Directory.GetParent(Directory.GetParent(sourceFolder).FullName).FullName
destPath = Path.Combine(grandParent, Path.GetFileName(file))
File.Move(file, destPath)
End For Each
Use an Invoke Code activity