Robocopy Scripts - batch-file

So I am looking for a nice batch file using the robocopy function to make a copy of my Win7 client machines Backup and Restore folders to a NAS. Each day a new folder is created in a backup set parent folder, so in theory, all I want robocopy to do is copy that new folder every night rather then the entire directory every night.
As of now - I am using robocopy /MIR but it still copies everything across each time as OLDER even though the folders haven't changed.
Any ideas how this can be done?
Cheers

Use the /XO option.
/XO : eXclude Older - if the destination file exists and is the same date
or newer than the source - don’t bother to overwrite it.
Another option would be to use the /MaxAge:1 option.
/MAXAGE:n : MAXimum file AGE - exclude files older than n days/date.
RoboCopy /?

Related

where is my batch file?

I made several bat files using task scheduler(custom) and I need to apply these to all of my 70 server computers. Obviously I don't want to repeat the same procedure at every server.
Can I simply copy and paste my bat files to different computers and expect same result?
If so, where are my bat files and where should I paste them?
Simply copy your batch files to different servers.
This post here shows location of task scheduler.
Folder location:
%systemroot%\System32\Tasks
Registry:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Taskcache\Tasks
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Taskcache\Tree
You may want to try the xcopy and for command to send your batch file to all servers.
Command syntax:
FOR command can loop through your server names, and XCOPY copys the batch script to the other servers.
for %%G in (serverA
serverB
serverC
...
serverZ) do xcopy [source] [destination] [options]
Note that asterisks does not work as intended, since it works as a wildcard.

Need help writing .bat file which changes all file permissions in a folder to Everyone

I appreciate your time so I won't take much of it. Here's what I'm trying to do: I want to create a .bat file that, when executed, will open the Command Prompt program, change directory to a folder (located on the C:), then execute a line of code that will change the file permission status of all files in that folder to Everyone. I intend to create a Windows task that will run this .bat file everyday. I understand how to setup the Windows task, but I can't figure out exactly how the .bat file should be written. Can anyone help?
Here's what I've got so far:
ECHO OFF
[Tab]Start "" C:\Windows\system32\cmd.exe
ECHO OFF
[Tab]Prompt cd cd:\google drive
ECHO OFF
[Tab]Prompt cacls *.* /t /e /g everyone:f
If you're interested, here's why I'm trying to create this .bat file:
I use a single Google Drive account on two file server computers, one in each of two offices. Each office has this file server and about 10 client computers. The client computers access files on the shared Google Drive folder (located on the file server) and occasionally add/edit/delete files. Google Drive does a great job of keeping all files synced between the two offices, but one problem I have is that if office A adds a file, the only computer in office B that can see it is the file server. I have to change the file permission to "Everyone" using the file server in office B before any of the client computers in office B can see the file. Over time, it's become very annoying to manually change the file permission every day and I'm looking for a shortcut. Please let me know if you can think of a better one.
If you got the commands right then this is a batch script with them.
The && will run the following command only if the cd command was successful.
#echo off
cd /d "c:\google drive" && cacls *.* /t /e /g everyone:f

Batch script to archive logs by zipping

I have a requirement for a batch script. I have log file under below directory (actually multiple directories with different names under E:\TIBCO\).
E:\TIBCO\*\6.0.0\LogFiles with Spotfire.Dxp.Automation.*.*
I need to perform below steps with the batch script
move (copy and delete) all the files that are with Spotfire.Dxp.*.*.* (ex Spotfire.Dxp..1.) from the above paths to E:\TIBCO\logsArchival\rotatedDir
zip all the files that are older than 60 from E:\TIBCO\logsArchival\rotatedDir to E:\TIBCO\logsArchival\ArchiveDir
delete the zip files that are older than 120 days from E:\TIBCO\logsArchival\ArchiveDir
All the above steps need to be written to the logs.
Please take a look at these links, where your requirement has been addressed before:
MS Dos Batch delete old files in directory and Batch file to delete files older than N days
You can easily customize those scripts to accomplish the remaining compression of the files. Please note, that in DOS the compress command is COMPACT. Use COMPACT /H for usage information.

Windows Batch Programming

I have some files that are automatically generated by an external sources into a local machine each day.
I have batch script, which moves the data from that source folder into a destination folder.
So i would like to move the files using time and date. But the robocopy command only accepts date.
Please see the script below
robocopy \\IP\f$\EMAILMT\202 C:\IntellinxServices\Queues\SwiftGen\MT202 *.rje /MAXAGE:%NEWDATE%

How can I backup target files with xcopy?

I change my project files on live by copying only the changed files with one xcopy command. Is it possible to back-up the target files (only the changing ones) into another location with xcopy? Or with a batch script?
Sorry, my question is not clear enough, here are some further explanation:
I have files in folder A that I xcopy to folder B. But I need to backup the files in folder B that are overwritten. How can I do this the easiest way?
Thanks.
xcopy /d
from the xcopy help
/D:mm-dd-yyyy
Copy files changed on or after the specified date.
If no date is given, copy only files whose
source date/time is newer than the destination time.

Resources