Insert current date in to destination folder structure - robocopy

Is it possible to insert todays date in Scandinavian format (yyyymmdd) in to the destination folder when using robocopy ie
robocopy "\\myserver\newlayout" "\\myserver\oldlayout 20120511" /MIR
I just need to support this while we transition our folder structures.
Cheers
Aha I've solved it by looking at other answers.
set "myDate=%date:~6,4%%date:~3,2%%date:~0,2%"
robocopy "\\myserver\newlayout" "\\myserver\oldlayout %myDate%" /MIR

Even easier, you could do it with the single line:
robocopy "\\myserver\newlayout" "\\myserver\oldlayout %date:~6,4%%date:~3,2%%date:~0,2%" /MIR

Related

Robocopy - Copy Files By Date Instead Of By Filename

By default Robocopy copies files in order by their filenames. I want to copy the files by date (or date modified) because they appear by date to the end user. (They have no sort, date is the default and only option.)
I have this:
robocopy "C:\directory" "D:\directory" /MIR /R:5 /W:20 /TEE /NP /LOG:"C:\Log.txt"
It is a simple directory copy. Is there a way within Robocopy to copy files by date (or date modified) instead of by filename?
Thank you.

Robocopying multiple folders at one time

I have a folder per day in c:/place/, like C:/place/2017-01-01 & C:/place/2017-01-31
I want to use robocopy to move 2017-01-0* from c:/place to d:/place, what would be the proper syntax to move all of those folders at once?
I'm using PowerShell to accomplish the task, but I don't want to use a do/FOR as moving one folder at a time would take far too long.
$source = "c:/place"
$dest= "d:/place"
robocopy $source $dest /COPYALL /B /SEC /MIR

RoboCopy /minlad not working

Trying to use robocopy to move folders that haven’t been modified in 24 hours, with some exclusions. But when executed, all the folders bar the exclusions are moved, this means that folders that have been modified in the last 24 hours are moved as well,
I’ve tried also tried /minage to try and test if it was just me, but there was no difference.
I removed the full file paths as they included my full name
robocopy C:\File1 C:\2Delete *.* /E /XD C:\2Delete /move /MINLAD:1 /Xd "C:\Other" /Xd "C:\Public" /Xd "C:\Default" pause

robocopy /MIR - don't delete desktop.ini in destination

I want to sync folders between two computers, one with XP and one with Vista. I want the two folders mirrored, except for security settings and folder settings. It is my understanding that /MIR switch will delete any 'extra' files in the destination folder, which would include the desktop.ini files. I can avoid copying desktop.ini files with /XA:SH How can I prevent robocopy from deleting the destination desktop.ini files?
If I have to do any extra scripting, I prefer PowerShell. But I hope robocopy can do it on its own.
Thanks.
/XF desktop.ini
Will exclude Desktop.ini (from copy or purge).
Replace the /MIR switch with /E, and don't use the /PURGE parameter.
Explanation: /MIR is the equivalent of using /E /PURGE, so by using /E without /PURGE, you achieve the results you desire.
Create a bat file so you can mirror the source at the destination and later once the mirror process is finish erase the files you desired.
For example:
robocopy SOURCE DEST /E /PURGE or /MIR or /E
command to erase recursively (test the command before running at production):
del /s DRIVe:\DESTINATION\desktop.ini
Hope this helps,
Luis

Robocopy copy contents of current folder

How would you translate this xcopy command into Robocopy:
xcopy *.* "C:\DestinationFolder\"
Keeping in mind that the current folder where the command is run changes dynamically (and hence the source folder is unknown in advance).
Thanks.
robocopy . "c:\dest"
Note you don't need to specify a wildcard in robocopy, by default it copies everything unless you use the /xf /xd flags to exclude certain files.
Robocopy DOES support wildcards.
You're expecting > robocopy SOURCE DEST but type > robocopy *.txt c:\folderdest\ to copy the current folder. If you look at the output from robocopy it will show "Files : *.txt" and "Source = c:\folderdest"
So in fact you can do > robocopy WILDCARD SOURCE DEST. If you want to use the CURRENT folder you need to use . (as has been mentioned here). So you would use > robocopy *.txt . c:\folderdest\.
Screenshot: http://i.stack.imgur.com/Xyxt4.png
As an addition:
If robocopy is started from an administrator console, the current folder "." will point to Windows\system32.
You can use the following commands at the top of your batch file to fix this:
#setlocal enableextensions
#cd /d "%~dp0"