I want to make a batch that auto uploads important files from the user that is using the program. so what I did was %username% in the directory Ex. C:\user\%username%\importantfiles

open (ftp server name)
(ftp user-name)
(ftp password)
prompt
bin
mput c:\user\%username%\importantfiles 

There are many users that must be able to use this..

So the "C:\user\mike\importantfiles" will not work

So the question is How do you specify the username in ftp upload

有帮助吗?

解决方案

You will need to generate the ftp script file from your batch.

Something like (just a skeleton)

....
set "ftpScript=%temp%\%~nx0.ftp.tmp"
(
    echo open (ftp server name)
    echo (ftp user-name)
    echo (ftp password)
    echo prompt
    echo bin
    echo mput "c:\user\%username%\importantfiles\*.*"
    echo quit
) > "%ftpScript%"

ftp -s:"%ftpScript%"
del /q "%ftpScript%" >nul 2>nul
....
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top