Windows Batch Programming - batch-file

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%

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.

Concatenate TimeStamp to File using Batch file

I have created two batch file that are working. Here is the outline
First Batch Calls another batch file
The second batch file changes to the directory on the application where the utility and command path to backup an asset resides, does the backup and places the file in C:\
I simple did a cd/ after the CALL command used to start second batch file to return to the path where the backup file is archived.
How do I use
set backupFilename=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
or other function to Concatenate to the backup file?
FileName_05-21-2015:09:30 Pm.txt
I am getting an error that the file does not exist when in fact it does. My intention is to use AT command or Schtask command to schedule this backup process every week. I will also appreciate more descriptive application of this commands too with time stamp for every backup completed on schedule

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.

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