實(shí)現(xiàn)FTP整站上傳的批處理代碼
更新時(shí)間:2014年07月15日 11:16:08 投稿:mdxy-dxy
這篇文章主要介紹了通過(guò)bat實(shí)現(xiàn)FTP整站上傳,學(xué)習(xí)批處理的朋友可以參考下
@echo off rem 設(shè)置FTP服務(wù)器地址 set ftpIP=192.168.0.2 rem 設(shè)置FTP用戶名 set ftpUser=MyUser rem 設(shè)置FTP密碼 set ftpPass=MyPass rem 設(shè)置待上傳的本地文件夾目錄 set UpFolder=C:/test rem 生成待上傳的本地文件夾列表 type nul>%temp%/FolderList.txt for /r "%UpFolder%" %%a in (.) do ( set FullName=%%a setlocal enabledelayedexpansion set FolderName=!FullName:%UpFolder%=! set FolderName=!FolderName:~1,-2! echo,!FolderName!>>%temp%/FolderList.txt endlocal ) >"%temp%/ftpFile.txt" echo,%ftpUser% >>"%temp%/ftpFile.txt" echo,%ftpPass% >>"%temp%/ftpFile.txt" echo bin >>"%temp%/ftpFile.txt" ( for /f "usebackq tokens=*" %%a in ("%temp%/FolderList.txt") do ( echo cd / echo mkdir "%%a" echo cd "/%%a" echo mput "%UpFolder%/%%a/*.*" ) ) >>"%temp%/ftpFile.txt" echo ! rd /s /q "%UpFolder%" >>"%temp%/ftpFile.txt" echo ! md "%UpFolder%" >>"%temp%/ftpFile.txt" echo bye ftp -v -i -s:"%temp%/ftpFile.txt" %ftpIP%