I have a ton of user directories, that I need to move along with permissions to another location, the command I use on an individual basis is :

robocopy "\filer\home" "h:\UserHome" /E /SEC /Copy:DATSOU /log:c:\logfile.txt

Is there a way that robocopy can point to a list of directories in a test file, that need to be moved, instead of doing it one by one which is the way im currently doing.

  • What version of Windows – Ryan Ries Dec 12 '14 at 13:33

Create a file named directories.txt:


Then write a Powershell script named RobocopyDirsFromList.ps1:

Foreach ($Directory In Get-Content .\directories.txt)
    robocopy "$Directory" "h:\UserHome" /E /SEC /Copy:DATSOU /log:c:\logfile.txt 

Note: I've not tested this, please test first.

  • Couldn't get this to work, tried a few different scenarios, the directories I put in as \\servername\folder\username but the script flashed up a command screen then disappeared. Didn't create a logfile either, im local admin on the server, and have all the permissions. – JJJJNR Dec 19 '14 at 9:55

You need to create folder list file

copy this script and save as BAT/CMD file:

for /f "tokens=*" %%a in (list.txt) do robocopy "%_source%\%%a" "%_dest%\%%a" /E /SEC /Copy:DATSOU /log:c:\logfile.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.