none
Robocopy Into New Directory RRS feed

  • Question

  • I am looking for a switch (that I haven't found yet) or a way for RoboCopy to copy into a newly created destination file such as:

    D:\Webs_Databases\041114 Where the 041114 folder has already been changed.  I know RoboCopy will create new directories, but I would like RoboCopy to copy into a newly created directory that is already created by another process.

    That directory name changes each day with the date.

    Any suggestions or a different way to look at this issue?

    Thanks in advance!

    Much appreciated! Brett

    Friday, April 11, 2014 4:00 PM

Answers

  • Can you try the below code

    $source="C:\PowerSQL"
    $date=Get-Date -UFormat %d%m%y 
    $dest="C:\temp\$date\"
    
    $what = @("/COPYALL","/B","/SEC","/MIR")
    $options = @("/R:0","/W:0","/NFL","/NDL")
    
    $cmdArgs = @("$source","$dest",$what,$options)
    robocopy @cmdArgs

    --Prashanth

    Friday, April 11, 2014 7:51 PM

All replies

  • Let me rephrase your question:

    You want a robocopy target directory name to be a string based on the current date.

    Is that correct?


    -- Bill Stewart [Bill_Stewart]

    Friday, April 11, 2014 4:50 PM
    Moderator
  • Yes that is correct.  Like mmddyy.

    The target directory is already created each day with another job.
    I would like RoboCopy just to drop the files into that directory.

    Thanks!

    Friday, April 11, 2014 6:22 PM
  • Can you try the below code

    $source="C:\PowerSQL"
    $date=Get-Date -UFormat %d%m%y 
    $dest="C:\temp\$date\"
    
    $what = @("/COPYALL","/B","/SEC","/MIR")
    $options = @("/R:0","/W:0","/NFL","/NDL")
    
    $cmdArgs = @("$source","$dest",$what,$options)
    robocopy @cmdArgs

    --Prashanth

    Friday, April 11, 2014 7:51 PM