0

I hate odd, almost useless apps on my PC. I don't want them to hang in there running and waiting for me use it once in a week. So I thought the instant fileshare could be done using almost only Windows tools.

I found how to send file to FTP using command line so the rest of the trick should be to copy a filename and add the FTP URL before it. Sounds like easy task but I can't see any option to copy a filename using batch file or whatever

The easiest and clean way to achieve that I found is to make an AutoIT script, compile it to exe with send to ftp command line options. I think I could google all of the code to do that. Any suggestions?

1
  • Now (after answering) I'm not sure if I understand your question. Do you already have the upload script and you want URL (to download the file back, like to send it via email to someone)? Or do you need the URL to upload the file (because a tool you use for upload uses a URL to specify an upload target)? Jul 9, 2015 at 6:43

2 Answers 2

0

Create a batch file that runs ftp.exe and takes a file path as an argument.

(I assume that ftp.exe is what you use to "send file to FTP using command line".)

Example:

@echo off
set FILE=%1
set SCRIPT=%TEMP%\ftp.txt

echo open example.com > %SCRIPT%
echo username>> %SCRIPT%
echo password>> %SCRIPT%
echo cd /path >> %SCRIPT%
echo put %FILE% >> %SCRIPT%
echo bye >> %SCRIPT%

ftp.exe -i -s:%SCRIPT%

Create a shortcut to the batch file in %APPDATA%\Microsoft\Windows\SendTo (i.e. typically in C:\Users\username\AppData\Roaming\Microsoft\Windows\SendTo).

Now the shortcut will appear in Send to submenu in Windows Explorer's file context menu. If you click it, the Windows Explorer runs the batch file, automatically passing path to a selected file to the script as a command-line argument.

Note that the script as is won't work when multiple file are selected. But it's not difficult to improve it to support multiple files.


To insert an URL of the file to a clipboard, use %~nx1 to extract filename only, use it to assemble the URL and pass the result to clip.exe:

echo ftp://localhost/%~nx1| clip

(just put this line to the end of the batch file)

8
  • Thanks Martin. Yes ftp.exe I'll dig batch file knowledge this evening, as for now I didn't get the variable thing. %SCRIPT% Jul 9, 2015 at 7:10
  • The %SCRIPT% stands for a path to a (temporary) ftp script file created by the echo lines. It's just so that the path is not repeated on every redirect like >> %TEMP%\ftp.txt Jul 9, 2015 at 7:26
  • You confused me with %SCRIPT% in every line. I'm not really into bach code but I saw the recursive behavior of a file read the file it creates, again and again. So looks like that first time ftp.txt should be created manually with username and password. Jul 9, 2015 at 16:57
  • After a bit of testing and understanding stuff I did it!! I needed some lame explanation yesterday like yourUsernameHere yourPassword, no space after it. And I do found that you missed one needed parameter, it's so stupid that we must remember it in 2015 year — type binary.So yes, the second part that I need is to copy the resulting URL of a new-shared file to clipboard. Sorry I removed the acceptance but if you need it I'll get it back, because you helped a lot. Jul 9, 2015 at 21:22
  • Allright! I've got one last piece to add to handle the entire task via batch file. I need to get the exact filename.ext of the %1, in opposite of full filepath. So the trick is almost usable, all you'll need is to crop the filepath. to get it - 'echo yourFTPURLasText /%1| clip' Jul 9, 2015 at 22:40
0

So here is the answer. I used Cyrillic characters «Ъ» to point the ЪexactЪ things that should to be changed with your FTP info, no spaces after unsername nor password

@echo off
set FILE=%1
set SCRIPT=%TEMP%\ftp.txt
echo ЪYourFTPserverHEREwithShareFolderЪ~nx1| clip
echo open ЪYourFTPserverHEREЪ > %SCRIPT%
echo ЪYourUsernameHereЪ>> %SCRIPT%
echo ЪYourPasswordHereЪ>> %SCRIPT%
echo cd ЪYourShareFolderHereЪ >> %SCRIPT%
echo type binary >> %SCRIPT%
echo put %FILE% >> %SCRIPT%
echo bye >> %SCRIPT%
echo ЪYourFTPserverHEREwithShareFolderForAsakeOfBigFilesЪ~nx1| clip
ftp.exe -i -s:%SCRIPT%

Create a shortcut to the batch file or the exact .BAT in %APPDATA%\Microsoft\Windows\SendTo (i.e. typically in C:\Users\username\AppData\Roaming\Microsoft\Windows\SendTo).

That batch say bye to tons of sharing websites about advertisements, just search for free ftp server and you can share on a snap

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .