Nice "custom action" in Thunar for extracting archives

Here's a useful custom action for Thunar. It extracts archives to a directory with the name of the archive.

The command:

Unpack to folder:
for file in %F; do 7z x "$file" -o`echo "$file"|sed 's/\.\+\(zip\|rar\|7z\|gz\|gzip\|bz2\|bzip2\).*$//g'`;done
...for this pattern:


Un-tar to folder:
for file in %F; do dir=`echo "$file"|sed 's/\.\+\(tar\|tgz\|tbz2\|txz\).*$//g'`;mkdir "$dir";cd "$dir";tar xf "$file";cd -;done
...for this pattern:

Example: This would extract the file name bla-1.2.3-foobar.tar.gz to the folder bla-1.2.3-foobar, instead of in the root of the current directory.