This is list of custom commands that users of WinSCP found useful. You are encouraged to add your own. Also check the built-in examples.
tar -xvzf --directory="!?&Extract to which directory:?.!" "!"
tar -czvf "!?&Enter an Archive Name:?archive.tgz!" --exclude="!?&Exclude files matching pattern:?*.exe!" !&
To unpack to the current directory:
unzip "!"
To unpack to an alternate directory:
unzip -d "!?&Extract to directory:?.!" "!"
To create an archive:
zip "!?&Enter an Archive Name:?archive.zip!" !&
rar a -ep "!?&Enter an Archive Name:?archive.rar!" !&
Use following command to quickly delete large directory structures:
rm -f -r "!"
The same command can ask for confirmation before deleting:
test "!?Do you really want to delete ?no!" == "yes" && rm -rf !&
Use following command if current protocol does not allow changing ownership:
chown "!?New owner:?!" !&
To change group use chgrp instead of chown. Or use following command:
chown "!?New owner (and group: user.group):!" !&
Example shows how to launch simple PHP script that maps file path to URL.
echo '<?="http://www.example.com".
str_replace("home/user/public_html", "~user", "'`pwd`'").
"/!\n"?>' | php -q
Hints:
http://www.example.com with right URL prefix, home/user/public_html with right path prefix and ~user with right URL replacement (it can even be empty in some cases).user with '`whoami`'.Another example using shell commands only, in case PHP is unavailable.
echo 'http://www.example.com'`pwd`'!' | sed s#home/lgtngstk/public_html#~user#
cp /path/to/template.html "!?&New HTML file:?!"
tail "!"
You may specify further how much to transfer, e.g.
tail --lines 2000 "!"
Check custom command option Show results in terminal.
find . -name "!?Search for files:?!"
Check custom command option Show results in terminal.
grep -H -r "!?Search for text:?!" * | cut -d: -f1
Check custom command option Show results in terminal.
cp ! $(echo "!" | sed "s/\..*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }')
mv ! $(echo "!" | sed "s/\..*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }')
Use following remote custom command to transfer selected remote files to an another server:
scp -p -r !& !?Username:?!@!?Host:?!:!?Destination path:?!
You may want to hard-code the Username and Host, if you work with one destination server only. Or you can use a single prompt for both (possibly even for Destination Path) to keep the flexibility, yet to reduce number of prompts:
scp -p -r !& !?Username@Host:?!:!?Destination path:?!
Note that you need to ensure you can connect and authenticate to the destination server without any prompts:
Site design by Black Gate