DOS Batch file to move 2000 files every 10 minutes - dos

Is it possible to create a DOS script that will move 2000 files to another folder every 10 minutes?
For example:
C:\MyFolder\
Every 10 minutes move 2000 files to C:\MyNewFolder\
Thank you!

I would use something like xcopy as recommended, however I would use the date flag to specify only copying new files. Just omit the date and it will copy only newer files.
/C Continues copying even if errors occur.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/E Copies directories and subdirectories, including empty ones.
xcopy C:\Source Z:\Destination /C /D /E

Use Schtasks.
You may want to look here: http://technet.microsoft.com/en-us/library/bb490996.aspx

Related

How to copy new files only in a folder to another one in Windows?

I am looking for a way to copy new files only from a folder to another one. The criteria are:
No PowerShell.
No software, just batch shell.
Timestamp in milliseconds or seconds, not minutes.
No sync. Files on folder B can be deleted, I only need new files from folder A to by copied.
Workflow:
Watch folder A.
New file written, copy to folder B.
I have tried with xcopy and robocopy but as far as I understand, using the timestamp in both is in days while I want to compare the timestamp in milliseconds.
XCOPY
/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.
ROBOCOPY
/minage:<n> Specifies the minimum file age (exclude files newer than n days or date).
The ideal solution I have in mind (forgive my ignorance here as I am not a windows user):
#REM new_only.bat
CURRENT_TIME=%date%%time%
SOURCE_DIR="c:\source"
TARGET_DIR="c:\target"
:start
xcopy %SOURCE_DIR% %TARGET_DIR% /time>%CURRENT_TIME%
goto start

Batch file to delete files after a certain amount of time in folder?

Is there a way I can create a batch file to delete files from a folder if they are in there for a certain number of days.
For example:
A files is in folder "edited" and has been there for a month, and if a file is in there for a month of longer, the batch file deletes it.
I'm guessing I would create a batch file then have it run on a schedule to check for files that have been there too long, I just don't know how to write the batch file.
Thanks in advance!
Googled a little, seems this is the solution:
forfiles -p "c:\your\folder" -s -m *.* /D -<number of days> /C "cmd /c del #path"
Change “C:\your\folder” to the directory to which you are saving the files you want to delete on a schedule. Note that the -40 refers to the day after which all files should be deleted so change the -40 if required.
Have a look at this post Batch file to delete files older than N days

Need a batch file to copy new and changed files

I need to copy files from one location to another location, but only copy new files, or files that have changed.
For instance, I have data in C:\Working which includes folders and files. The files are changed, and removed from there as they are no longer needed or a project is complete.
I need a batch file to move everything in that location to D:\Storage. Since some files may not have changed, I do not want to copy those, however, I do want to copy and replace files that have been modified.
I believe I can use Robocopy /E and that will give me the recursion that I need. I am not sure on how to check hashes or stamps to verify if the file has been changed. I know I can EXCLUDE files with the /XC, but I think that's the opposite of what I want.
Right now my file as as folows:
#echo off
pushd C:\Working
>nul Robocopy /E . D:\Storage
popd
Edit: I don't want to just copy everything because the working location may have upwards of 60GB in it, and only 1-2GB needs to be copied.
http://ss64.com/nt/robocopy.html
By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes.
Therefore, Robocopy . D:\Storage /E should be fine. You may want to add the /XO option depending on what you want.

Dos command xcopy to have current date - 90 days variable

i need to a .bat file to copy with xcopy command the files from a specific directory that are 90 days new. that means to take the todays date and take out 90 days of it and do not perform the copy.
help is needed,
thx
Use ROBOCOPY not XCOPY. It will do what you want very easily. Robocopy is installed on Windows 7 and is a free download for other versions.
ROBOCOPY /S /MAXAGE:90 P:\path\to\source Q:\path\to\dest
There are many other options, for minimum age, min and max size, attrributes, filtering by file and directory names, and so forth.
Also you can use the /L option to just list what it would have done, to check you have the other options right.

Incremetal backups of directories with a batch/shell script

I'm trying to create a script that will automatically backup a complete directory tree. I also want it to work for incremental backups. Basically, it wil work like this:
If file is in both source and destination and they are different, source file will be copied
If file is in both source and destination and they are the same, nothing will be copied
If file is only in the source, source file will be copied
If file is only in the destination, destination file will be deleted.
I'm still new to shell scripting and I'm not sure how I could implement this. Any ideas? Windows batch scripts would be better, but shell scripts that run on Cygwin are also fine.
Take a look at rsync tool - it was designed to minimize traffic during files synchronization.
Also, probably "cp" with "-u" argument will be useful:
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing
For windows batch scripting xcopy (native to windows) or robocopy (a free download in windows) both work extremely well.
An example xcopy script (in a .bat file):
#echo off
:: /L = list only.
:: /v=Verify, /y=No prompting /s=subdirs /z=Network mode (supports bad)
:: /i=Tells xcopy dest is folder /f=Display names /d=Copy only changed
echo Backing up projects...
xcopy e:\projects h:\projects /V /Y /S /Z /I /F /D
It will even support orphaned files (if you delete something from your source you no longer need a copy in the backup). Xcopy is typically fine for your needs until you deal with sync between NTFS and Fat32 file systems - the later only has a 2 second resolution and problems with daily savings time so you occasionally run into issues: (a) on time change day you might not get a backup of a changed file - depends on change-regularity of course or you might get a backup of all files even though none have changed (b) because of time resolution some files may backup even though they haven't changed.

Resources