robocopy

Robocopy Files Only and Not Sub Folder Structures


I'm trying to Robocopy files from a directory that has about 100 subfolders with thousands of files in each subfolder to a Single Folder. I don't need the subfolder structure, I just need the files out of each subfolder.

Is there a switch to exclude copying over the folder structures using just Robocopy? I'm trying to stick with just Robocopy to eliminate any extra validation when doing custom code.

The is a sample of what I have together already and just need to plug in that exception.

robocopy SourceFolder DestinationFolder "keywordInFileName*" /S /COPY:DATSOU /DCOPY:DAT /IS /R:10 /W:5 /LOG+:C:\RoboCopyLog%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%.txt

Can't find anything using just Robocopy.


Solution

  • I am afraid robocopy cannot ignore the tree structure, because it is a tree-copy/tree-sync program.

    Preselecting the files and feeding them to robocopy via a jobfile might work, but I did not look into the jobfile capabilities any further. This would be up to you. See the robocopy option /JOB:filename as a starting point or search for the robocopy manual/documentation online.

    I think you are better off just making a call for each subfolder, as was suggested in the comments.