Board logo

标题: [FTP] 批处理实现FTP整站上传 [打印本页]

作者: HAT    时间: 2011-5-27 02:04     标题: 批处理实现FTP整站上传

  1. @echo off
  2. rem 设置FTP服务器地址
  3. set ftpIP=192.168.0.2
  4. rem 设置FTP用户名
  5. set ftpUser=MyUser
  6. rem 设置FTP密码
  7. set ftpPass=MyPass
  8. rem 设置待上传的本地文件夹目录
  9. set UpFolder=C:\test
  10. rem 生成待上传的本地文件夹列表
  11. type nul>%temp%\FolderList.txt
  12. for /r "%UpFolder%" %%a in (.) do (
  13.     set FullName=%%a
  14.     setlocal enabledelayedexpansion
  15.     set FolderName=!FullName:%UpFolder%=!
  16.     set FolderName=!FolderName:~1,-2!
  17.     echo,!FolderName!>>%temp%\FolderList.txt
  18.     endlocal
  19. )
  20. >"%temp%\ftpFile.txt" echo,%ftpUser%
  21. >>"%temp%\ftpFile.txt" echo,%ftpPass%
  22. >>"%temp%\ftpFile.txt" echo bin
  23. >>"%temp%\ftpFile.txt" (
  24.     for /f "usebackq tokens=*" %%a in ("%temp%\FolderList.txt") do (
  25.         echo cd \
  26.         echo mkdir "%%a"
  27.         echo cd "\%%a"
  28.         echo mput "%UpFolder%\%%a\*.*"
  29.     )
  30. )
  31. >>"%temp%\ftpFile.txt" echo ! rd /s /q "%UpFolder%"
  32. >>"%temp%\ftpFile.txt" echo ! md "%UpFolder%"
  33. >>"%temp%\ftpFile.txt" echo bye
  34. ftp -v -i -s:"%temp%\ftpFile.txt" %ftpIP%
复制代码
首发:http://blog.csdn.net/ljc007/archive/2010/04/17/5497018.aspx




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2