RoboCopy Excel List of Directories

RoboCopy Excel List of Directories

There are times that you want to take advantage of Robcopy's multi-threading capabilities and also have several different directories that you need to

Packet Capture with PowerShell
Sophos Cleanup Script
Cleanup Windows

There are times that you want to take advantage of Robcopy’s multi-threading capabilities and also have several different directories that you need to copy to different locations, whether it be different drive locations or shares. This little PS script will do just what you need and create you a separate log file for each.

  1. Download the FileMover.zip (located at the end of this article) and extract the FileMover.ps1
  2. You need to have a copy of robocopy.exe in the same path as the FileMover.ps1 script.
  3. Create an excel file called Shares_Robo.csv and save it also in the same path as the FileMover.ps1 script. It should have three column headers “Source, Destination, LogName”.
  4. Remember to uncomment the line in FileMover.ps1 that you want to use depending on permissions and multi-threading.

The excel file should look like this:

 
FileMover.ps1 Contents

$scriptpath = $MyInvocation.MyCommand.Path
$currentdir = Split-Path $scriptpath
$command = $currentdir + "\robocopy.exe"
$newdir = $currentdir + "\logs"
$newdir
mkdir $newdir -force
#import "Shares.txt" into an array
$importloc = $currentdir + "\Shares_Robo.csv"
$input = import-csv $importloc
#cycle through array
foreach($Item in $input){
$time = Get-date -Format s
$log = $Item.logname
$log = $log + "_" + $time
$log = $log.replace(":", "-")
$log = $currentdir + "\logs\" + $log + ".txt"
#use the below if you DO NOT want to copy security permissions
#& $command $Item.Source $Item.Destination /E /copy:DAT /R:3 /W:1 /V /TS /FP /NP /log:$log
#use the below if you DO want to copy security permissions
& $command $Item.Source $Item.Destination /E /copy:DATSOU /SEC /R:3 /W:1 /V /TS /FP /NP /log:$log
# If you want to take advantage of Multi-threading also use /MT:xx (with xx being the number of threads you want)
}

Download FileMover Now!
FileMover.zip (26 downloads)

 

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of