:: Script to sync files (who needs a GUI!) :: Syntax: XCOPY source [destination] options :: :: /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. :: /EXCLUDE:file1[+file2][+file3]... :: Specifies a list of files containing strings. Each string :: should be in a separate line in the files. When any of the :: strings match any part of the absolute path of the file to be :: copied, that file will be excluded from being copied. For :: example, specifying a string like \obj\ or .obj will exclude :: all files underneath the directory obj or all files with the :: .obj extension respectively. :: /S Copies directories and subdirectories except empty ones. :: /E Copies directories and subdirectories, including empty ones. :: /V Verifies each new file. :: /C Continues copying even if errors occur. :: /I If destination does not exist and copying more than one file, :: assumes that destination must be a directory. :: /F Displays full source and destination file names while copying. :: /L Displays files that would be copied. :: /H Copies hidden and system files also. :: /R Overwrites read-only files. :: /U Copies only files that already exist in destination. :: /K Copies attributes. Normal Xcopy will reset read-only attributes. :: /Y Suppresses prompting to confirm you want to overwrite an :: existing destination file. :: /Z Copies networked files in restartable mode. @echo off :: Running in Windows NT or higher? if not "%OS%" == "Windows_NT" ( echo This script requires Windows NT or higher. pause exit /B 1 ) :: Set variables setlocal set log_file=C:\utils\sync.log set max_log_size=20000 set options=/D /V /I /F /H /R /K /Y /Z ^>^> %log_file% 2^>^&1 for /F "tokens=*" %%i in ('time /T') do set time=%%i :: Begin sync cd /D C:\utils echo %date% %time% >> %log_file% echo [Batch files] >> %log_file% xcopy C:\utils\*.bat I:\batch %options% echo [Configs] >> %log_file% xcopy C:\utils\Notepad2.ini "C:\Documents and Settings\tom\My Documents\software\configs" %options% echo [Demos] >> %log_file% xcopy "C:\Documents and Settings\tom\My Documents\demos\submission_process.html" \\shared\Demos %options% echo [Documentation] >> %log_file% xcopy "C:\Documents and Settings\tom\My Documents\documentation\*.doc" "\\shared\Content Binder\documentation\User" %options% xcopy "C:\Documents and Settings\tom\My Documents\specs\training\*.doc" \\shared\Datafeeds\Specs\training %options% xcopy "C:\Documents and Settings\tom\My Documents\specs\training\*.pps" \\shared\Datafeeds\Specs\training %options% xcopy "C:\Documents and Settings\tom\My Documents\specs\training\*.ppt" \\shared\Datafeeds\Specs\training %options% echo [Search] >> %log_file% xcopy \\shared\Search\Maintenance "C:\Documents and Settings\tom\My Documents\Search\Maintenance" %options% echo [PERSONAL.XLS] >> %log_file% xcopy "C:\Documents and Settings\tom\Application Data\Microsoft\Excel\XLSTART\PERSONAL.XLS" "C:\Documents and Settings\tom\My Documents\Excel" %options% echo [Tools] >> %log_file% xcopy "C:\Documents and Settings\tom\My Documents\auto_scripts\html_aide" \\shared\Content-Tools\html_aide %options% xcopy "C:\Documents and Settings\tom\My Documents\HTA\copy_tool.hta" I:\dev\tools %options% xcopy "C:\Documents and Settings\tom\My Documents\HTA\copy.js" I:\dev\tools %options% xcopy "C:\Documents and Settings\tom\My Documents\HTA\history.txt" I:\dev\tools %options% xcopy "C:\Documents and Settings\tom\My Documents\HTA\tools.css" I:\dev\tools %options% xcopy "C:\Documents and Settings\tom\My Documents\scraper\datafeed_mapper.hta" I:\dev\tools %options% xcopy "C:\Documents and Settings\tom\My Documents\scraper\datafeed_mapper.ini" I:\dev\tools %options% xcopy I:\dev\tools\companion.html \\shared\Content-Tools %options% xcopy I:\dev\tools\copy.js \\shared\Content-Tools %options% xcopy I:\dev\tools\copy_tool.hta \\shared\Content-Tools %options% xcopy I:\dev\tools\count.html \\shared\Content-Tools %options% xcopy I:\dev\tools\cs_prepper.html \\shared\Content-Tools %options% xcopy I:\dev\tools\dashboard_xml_gen.html \\shared\Content-Tools %options% xcopy I:\dev\tools\datafeed_mapper.hta \\shared\Content-Tools %options% xcopy I:\dev\tools\datafeed_mapper.ini \\shared\Content-Tools %options% xcopy I:\dev\tools\ds_prepper.html \\shared\Content-Tools %options% xcopy I:\dev\tools\history.txt \\shared\Content-Tools %options% xcopy I:\dev\tools\html_guide.html \\shared\Content-Tools %options% xcopy I:\dev\tools\hub_register.html \\shared\Content-Tools %options% xcopy I:\dev\tools\insp_xml_gen.html \\shared\Content-Tools %options% xcopy I:\dev\tools\keywords.js \\shared\Content-Tools %options% xcopy I:\dev\tools\kw_generator.html \\shared\Content-Tools %options% xcopy I:\dev\tools\specs_formatter.html \\shared\Content-Tools %options% xcopy I:\dev\tools\tools.css \\shared\Content-Tools %options% xcopy I:\dev\bookmarklets.txt \\shared\Content-Tools %options% xcopy I:\dev\javascript.txt \\shared\Content-Tools\javascript %options% xcopy I:\dev\sql_tips.txt \\shared\Content-Tools\sql %options% xcopy I:\dev\unix_tips.txt \\shared\Content-Tools\unix %options% echo [Unix] >> %log_file% xcopy I:\tom\bin \\shared\Content-Tools\unix\shell_scripts %options% echo. >> %log_file% :: Trim log if over max_log_size for /F %%i in ('dir %log_file% /B') do set log_size=%%~zi if %log_size% GEQ %max_log_size% ( set trim_log=1 set /A lines=log_size-max_log_size set /A lines=lines/20 if exist R: set temp=R: ) if defined trim_log ( more %log_file% +%lines% > %temp%\sync.tmp copy /Y %temp%\sync.tmp %log_file% > nul del %temp%\sync.tmp ) :: Open log on error if errorlevel 1 ( color 0c echo There were some problems with the sync. The log will be displayed in Notepad. echo. pause start notepad.exe %log_file% ) else ( echo All files are synced! ) :END endlocal