实现FTP整站上传的批处理代码
程序员文章站
2022-06-24 16:10:20
@echo off
rem 设置ftp服务器地址
set ftpip=192.168.0.2
rem 设置ftp用户名
set ftpuser=myuser...
@echo off rem 设置ftp服务器地址 set ftpip=192.168.0.2 rem 设置ftp用户名 set ftpuser=myuser rem 设置ftp密码 set ftppass=mypass rem 设置待上传的本地文件夹目录 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%
上一篇: 用批处理修改日期 然后在改回来