Question

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

Était-ce utile?

La solution

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
....
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top