-4

Just make my script to send files to a .ftp folder and it's working well, follow bellow:

@echo off & SetLocal
( echo open ftp.xxxxx.com.it
echo username
echo password
echo put %userprofile%\Desktop\%date:/=-%.zip
echo bye 
)> %temp%\ftpsend.dat
ftp -s:%temp%/ftpsend.dat
del /f /s /q %temp%\ftpsend.dat
pause

But using %userprofile% it can't set the user. My computer username is !Karen Dallalibera! maybe is beacause the ! in the username....but don't haveDelayExpansion, so i don't know.

I want use %userprofile%, %homepath%, etc.

There's a way to use it?


Got it, using ". But there's another problem: I want upload the file into a especific folder, i tried as below:

    @echo off & SetLocal
    ( echo open ftp.xxxxx.com.it
    echo username
    echo password
    cd \Karen D.\Test\
    echo put "%userprofile%\Desktop\%date:/=-%.zip"
    echo bye 
    )> %temp%\ftpsend.dat
    ftp -s:%temp%/ftpsend.dat
    del /f /s /q %temp%\ftpsend.dat
    pause

I wanted to upload the files to the folder \Karen D.\Test\ But the script is saving on the main folder of the ftp. How can i set the specific folder for uploading?

Lalalala
  • 165
  • 1
  • 2
  • 9
  • Should your first line be : `echo OPEN ftp://ftp.xxxxxx.com.it/ > ftpcommands.txt` so that it creates the file as a new one, rather than appending to an existing one? – Dragonthoughts Jun 16 '18 at 19:28
  • "nothing happens" is unlikely. Does `cmd` or `ftp` generate an error message? Is the file created? – Magoo Jun 16 '18 at 19:28
  • What Operating system are you running on? Is the FTP command installed? – Dragonthoughts Jun 16 '18 at 19:29
  • It says the host in unknown (but is right, already checked), i use Windows 7. – Lalalala Jun 16 '18 at 20:31
  • check my last edit! – Lalalala Jun 16 '18 at 23:36
  • If you've got a new question - please ask a new question. Don't vandalize your own question by changing the title and content. –  Jun 17 '18 at 08:05
  • @LotPings I ask you to delet your answer, for me delet the question and create another one. As you marked as duplicated, this question already exists and doesn't matter to anyone. – Lalalala Jun 17 '18 at 13:23
  • So let it be and post a new question. It will eventually get deleted automatically anyway, as it's closed and has negative score. – Martin Prikryl Jun 17 '18 at 16:58

1 Answers1

1

Don't precede literal user/password with anything

( echo OPEN ftp.xxxxxx.com.it/
  echo username
  echo password
  echo put %userprofile%\Desktop\%date:/=-%.zip
  echo quit
) >ftpcommands.txt
FTP -s:ftpcommands.txt