Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: How to script a daily copy of files w/dt being name of archive folder

29 May 2014   #1
pglufkin

windows 7 professional
 
 
How to script a daily copy of files w/dt being name of archive folder

Hello,

I need to figure out a Windows 7 script to copy/archive files which are located in a specific folder. It needs to copy daily to an archive folder, with the script creating the archive folder as MM-DD-YY (being that day's date that is being archived) before it archives the files to that folder. The script will run at 9:00 pm every night, the time all work ceases.

If anyone could help me with this script, I would appreciate it.


My System SpecsSystem Spec
.
29 May 2014   #2
Ztruker

Windows 10 Pro X64
 
 

If the archive was going to be D:\MyArchives and the source was C:\Users\youruserid\SomeFolder:

for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"

set datestamp=%MM%-%DD%-%YYYY%
echo datestamp: "%datestamp%"

md D:\MyArchives\%datestamp%
xcopy C:\Users\youruserid\SomeFolder\*.* D:\MyArchives\%datestamp%\ /s/h/r/i/k/e/y

Enter xcopy /? from a Command Prompt to see what the parameters mean.

Above found in a post by foxidrive here: Format date in Windows 7 batch job - Stack Overflow

My System SpecsSystem Spec
29 May 2014   #3
pglufkin

windows 7 professional
 
 

Thank you! So I put this is some .bat file and trigger it through Task Scheduler?

Sorry, I'm not sure exactly how to do this. I think I may know, but just not sure.
My System SpecsSystem Spec
.

30 May 2014   #4
Ztruker

Windows 10 Pro X64
 
 

Yes, put in a .bat file then schedule to run via Task Scheduler.

Test the heck out of it first though.
My System SpecsSystem Spec
Reply

 How to script a daily copy of files w/dt being name of archive folder




Thread Tools




Similar help and support threads
Thread Forum
Batch Script: How to Set the Number of Files to Copy or Move
HI All, I'm very new to batch programming and have a question about a task. I'm looking to create a batch programming script where I can copy 10 files at a time every 10 minutes to a destination folder until all files have been copied ex: select 1st 10 files to copy over,wait 10...
General Discussion
Is it possible to copy individual files in a folder to its own folder?
I have about 400 video files in a folder but I need to put each one in its own folder so I can use the jukebox function on my media player. Is there any way it can be done without having to transfer each file to an individual folder one by one?
General Discussion
VB script: Rename all files in a folder to a specified prefix
Hi, I'm trying to find help in entering paths and prefix's in my vb script. I am of course a newbie to visual basic and don't know where to enter the path and wording for prefix. Any help would be most appreciated. Rich
General Discussion
Can't copy Outlook archive file
I'm about to wipe an employees PC and I need to get the archive.pst off the PC first. The Archive file is 6.1GB in size but when I try to copy it to my 32G Flash Drive it says that the "archive.pst is too large for the destination file system." I've done this many times before with larger archive...
Microsoft Office
What image backup files to copy to archive device?
I am making regular backups - both the image backup and the file sets using Windows 7 Backup program. No problems with that. But, I periodically would like to copy the image backup to a portable drive. I plan to take this portable drive offsite to a secure location - I call it my archive. ...
Backup and Restore


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 06:41.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App