Send To .tar.gz

Corwin Joy corwin.joy@gmail.com
Wed Dec 1 18:35:00 GMT 2010


I use cygwin a lot and I wanted to create a windows XP "Send To" shortcut that
would allow me to "Send" a folder from windows explorer to a .tar.gz file. 
(Rather like the compress folder item, but compress to a .tar.gz format).  It
turned out to be fairly simple to create this, here is the code below in case
someone else wants to do this.

1. Create a script to compress a windows directory path. I called this
send_to_tar_gz.sh and placed it in my home directory.
---------
#!/bin/sh

bin=/bin # Executables in Cygwin space(Windows PATH may not include it)

if [ "${1}" = "" ];
	then
		XPATH=".";
	else
		XPATH="$($bin/cygpath -u -a "${1}")";
fi

echo "creating .tar.gz of" "$XPATH"

$bin/tar -cvzf "${XPATH}.tar.gz" "$XPATH"
-------

2. Create a windows "Send To" shortcut as explained here:
http://support.microsoft.com/kb/310270
C:\cygwin\bin\bash.exe --login -i send_to_tar_gz.sh

Note that I needed to use --login -i arguments because
a. I placed the shell script in my home directory.
b. If I just used bash the tar command had problems finding the gzip command to
compress the tar file, I'm not quite sure why.  Something to do with the path I
think.




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list