A small script that automatically synchronizes files under Windows

Source: Internet
Author: User


Share two of your own bat scripts that automatically synchronize files under Windows (Tiger O (∩_∩) o)


*******************************************************************

@echo off

Color 02

REM uses Goto and lftp to implement timed automatic uploading of files to the FTP server specified directory # #注释信息

: Loop

Echo.

Echo.

Echo =============================================

echo Start copy File after 5 second

TIMEOUT/T 5 # #每5秒复制一下

Echo Copying File ...

Lftp-f/cygdrive/Drive letter/directory/lftp.txt # f is the file path that specifies the lftp execution command

echo "Success"

Pause

Goto:loop



Lftp.txt # #这个文件里面的命令在上面lftp-F command can be called wherever you can write the corresponding path is OK

Open 10.0.2.168

User Cienet Cienet

Put/cygdrive/f/index/file.txt-o data/##/cygdrive/f/index is the path to the file to be uploaded in the index directory of the local F-drive-O is the corresponding directory to upload to FTP


Note: The lftp is used here because the FTP command does not seem to support passive mode, and I have lftp configured in the system environment variable

*******************************************************************


@echo off

Color 02

REM uses Goto and if to determine if a shared file exists and automatically copies files at regular intervals

Goto Start

: Start

Echo.

Echo.

Echo =============================================

echo Start copy File after 5 second

TIMEOUT/T 5

NET use \ \ shared ip\ shared directory "password"/user: Shared account # #访问共享

If exist file.txt goto COPY1 # # If the file.txt file exists then execute the command under copy1 otherwise execute the command under COPY2

Goto COPY2

: Copy1

Echo.

echo No File

TIMEOUT/T 2

Goto EOF # Exit script if no files are specified in the share to be copied

: Copy2

Echo.

Echo Copying File ...

NET use \ \ shared ip\ shared directory "password"/user: Shared account

xcopy \ \ Share ip\ shared directory \file.txt d:\/y

Goto Start # #跳回到start重新开始


: EOF

***************************************************************


This article is from the "Stop fleeting lb" blog, please be sure to keep this source http://liubin0505star.blog.51cto.com/5550456/1665095

A small script that automatically synchronizes files under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.