0

I need to flatten a directory structure. I have a very large directory with 6000+ directories and 40000+ files. Some are 12 levels deep and have files in them. The paths exceed 255 character limits and if you add the file names, some are 400 characters +. copy and xcopy will not work for this task. I tried a For /R loop with copy and xcopy and they fail at going beyond 255 character paths. I receive a file not found error. I know that robocopy is good for 36000 characters, so it seems to be the only option. is there anyway to script this in powershell or batch, vb? every variation I have tried copies the directory structure along with the files.

any help is appreciated.

maxim
  • 21
  • 3
  • Where do you want these files to be copied? For instance, if you have C:\files\department\TeamA\Source, and let say you want to copy these files to D:\Target. Do you want to recreate the whole directory structure, or just move the files themselves from Source to Target? – FoxDeploy Jul 09 '15 at 14:16
  • 1
    You can use robocopy for this. – Richard Jul 09 '15 at 14:20
  • > _every variation I have tried copies the directory structure along with the files_. And why is this bad? What exactly are you trying to achieve? – Alexander Obersht Jul 09 '15 at 16:45
  • so you want to go from a folder structure that is 12 deep to moving all sub files into a single directory? All individual files have a unique name? – ATek Jul 09 '15 at 22:58
  • 1
    I am trying to copy from a structured, multi-level directory to a flat structure. multiple directories into one. the files will have unique names (the names will be hashed prior to the move). – maxim Jul 10 '15 at 06:35
  • possible duplicate of [ROBOCOPY - Copy folders content to a single folder](http://stackoverflow.com/questions/8690245/robocopy-copy-folders-content-to-a-single-folder) – Helen Jul 10 '15 at 09:38

0 Answers0