0

I wanted to ask if anyone knew of a way to do something natively with Windows or PowerShell.

I'd call it a "File Funnel".

I want to be able to put files on a machine in a given folder, and have those files automatically transferred over time (much slower connection) to a network drive.

But I want it to be done reliably - meaning that I'd like the transfer to be done transactionally so the files aren't deleted until they've been verified on the other location.

Using it should be as simple as dumping the files in the folder - after the files have been transferred successfully, the folder would be empty.

  • Here are some google terms to get you started Powershell Filewatcher and Powershell BITS – EBGreen Jul 16 '18 at 14:45
  • Did you ever check out the answer I provided to see if it'd be helpful for your task? If something was not clear I am happy to further clarify. If you are still having trouble or anything else, I'd like some feedback from you to ensure I don't need to make adjustments to accommodate accordingly. – Pimp Juice IT Jul 25 '18 at 4:37
1

Sure you can do this with Robocopy using the /S and /MOV parameters to ensure the files in the source location are copied over to the destination location, and then remove the files from the source once the copy completes successfully.


Batch Script

SET SRC="Z:\path\source"
SET DEST="X:\path\destination"
SET FName=*.*
SET LOG=C:\Path\Log.txt
::   If you do not want a log file, remove the "/LOG+:%LOG%" below
SET OPT=/S /MOV /NP /R:5 /LOG+:%Log% /TS /FP
SET CMD=robocopy %SRC% %FName% %DEST% %OPT%
%CMD%

PowerShell Script

$SRC   = "Z:\path\source"
$DEST  = "X:\path\destination"
$FName = "*.*"
$OPT   = "/S /MOV /NP /R:5"
$CMD   = "robocopy $SRC $FName $DEST $OPT"
Invoke-Expression $CMD

Note: To automate you simply create a PowerShell or batch script with this syntax and schedule with Task Scheduler to run once an hour, every X minutes, etc. per your scheduling needs.


Further Resources

  • Robocopy

           /S :: copy Subdirectories, but not empty ones.
           /MOV :: MOVe files (delete from source after copying).
    
  • @BleakMorn - If you don't have subdirectories to copy per this process, then simply omit the /S parameter. – Pimp Juice IT Jul 16 '18 at 15:05
  • 1
    it is in the docs as linked, but Robocopy will also accept UNC paths (e.g. \\Fooserver\folder). – Yorik Jul 16 '18 at 17:24

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.