Created
March 19, 2013 15:13
-
-
Save ecos/5196943 to your computer and use it in GitHub Desktop.
A cool Windows batch script to upload a file to an FTP folder, and then copy the URL in the clipboard. Useful for posting screenshots quickly in a post on a forum.
You only have to change these parameters
SET Server=yourFTPserver
SET UserName=yourFTPusername
SET Password=yourpassword
SET RemoteFolder=/www/images/screenshots
SET ClipboardURLPrefi…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
ECHO Upload to FTP | |
ECHO Written by: Jason Faulkner | |
ECHO SysadminGeek.com | |
ECHO. Improved by ecos | |
ECHO. | |
REM Usage: | |
REM UploadToFTP [/L] FileToUpload | |
REM | |
REM Required Parameters: | |
REM FileToUpload | |
REM The file or file containing the list of files to be uploaded. | |
REM | |
REM Optional Parameters: | |
REM /L When supplied, the FileToUpload is read as a list of files to be uploaded. | |
REM A list of files should be a plain text file which has a single file on each line. | |
REM Files listed in this file must specify the full path and be quoted where appropriate. | |
SETLOCAL EnableExtensions | |
REM Connection information: | |
SET Server=yourFTPserver | |
SET UserName=yourFTPusername | |
SET Password=yourpassword | |
SET RemoteFolder=/www/images/screenshots | |
SET ClipboardURLPrefix=![](http://www.mywebsite.com/images/screenshots/ | |
SET ClipboardURLSuffix=) | |
REM ---- Do not modify anything below this line ---- | |
SET Commands="%TEMP%SendToFTP_commands.txt" | |
REM FTP user name and password. No spaces after either. | |
ECHO %UserName%> %Commands% | |
ECHO %Password%>> %Commands% | |
REM set remote path. | |
ECHO cd %RemoteFolder% >> %Commands% | |
REM FTP transfer settings. | |
ECHO binary >> %Commands% | |
IF /I {%1}=={/L} ( | |
REM Add file(s) to the list to be FTP'ed. | |
FOR /F "usebackq tokens=*" %%I IN ("%~dpnx2") DO ECHO put %%I >> %Commands% | |
) ELSE ( | |
ECHO put "%~dpnx1" >> %Commands% | |
) | |
REM Close the FTP connection. | |
ECHO close >> %Commands% | |
ECHO bye >> %Commands% | |
REM Perform the FTP. | |
FTP -d -i -s:%Commands% %Server% | |
REM Save URL to clipboard. | |
ECHO %ClipboardURLPrefix%%~nx1%ClipboardURLSuffix%| clip | |
ECHO. | |
ECHO. | |
REM Clean up. | |
IF EXIST %Commands% DEL %Commands% | |
ENDLOCAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very interesting... But if password has a "&" character, the script does not work. Even with quote around the password, it does not work, because quotes are not part of the password.