.bat file needed

tmigs
tmigs used Ask the Experts™
on
I need a .bat file that will move file9s) based on date modified from one folder to another and then delete older file(s) in the destination folder, i.e.:

move from F:\epic\epic_daily\backups\"filename.bak"(based on most recent date modified) to
Y:\...\...\...

once complete I would like to automatically delete the older file(s) in the folder on Y:\
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This is not a .bat file... but it will do what you are asking.

It is free for personal use.... otherwise I believe there is a fee for business use.

http://allwaysync.com/

I recently recommended this in another experts-exchange question... and the author really liked it after he tried it.
Hi,
Try to use Microsoft Synctoy 2.0 which will do the task that you are looking out for instead of creating batch file.
You can configure it to copy files from target to destination and keep or delete the files from the target.
Robocopy would be your best friend here. it is native with win7 and server 2008. can be downloaded from Microsoft site for XP and 2003.

there is ALOT of option in there including filtering on what to copy base on age/last access.

this is a snipet of the help ( robocopy /? )

You will see that all you need is here and even more. the tool is extensive and may take some time to tweak the command line as you need... but once you learn how it works, it is a BIG asset if you work in IT.

----------------------
::
:: File Selection Options :
::
                 /A :: copy only files with the Archive attribute set.
                 /M :: copy only files with the Archive attribute and reset it.
    /IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
    /XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

 /XF file [file]... :: eXclude Files matching given names/paths/wildcards.
 /XD dirs [dirs]... :: eXclude Directories matching given names/paths.

                /XC :: eXclude Changed files.
                /XN :: eXclude Newer files.
                /XO :: eXclude Older files.
                /XX :: eXclude eXtra files and directories.
                /XL :: eXclude Lonely files and directories.
                /IS :: Include Same files.
                /IT :: Include Tweaked files.

             /MAX:n :: MAXimum file size - exclude files bigger than n bytes.
             /MIN:n :: MINimum file size - exclude files smaller than n bytes.

          /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
          /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
          /MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.
          /MINLAD:n :: MINimum Last Access Date - exclude files used since n.
                       (If n < 1900 then n = n days, else n = YYYYMMDD date).

                /XJ :: eXclude Junction points. (normally included by default).

               /FFT :: assume FAT File Times (2-second granularity).
               /DST :: compensate for one-hour DST time differences.

               /XJD :: eXclude Junction points for Directories.
               /XJF :: eXclude Junction points for Files.
-----------------------------------

Author

Commented:
Thanks. This is exactly what I was looking for.

Thanks for the other responses but Robocopy is what the Dr. ordered.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial