Update authors lists
[claws.git] / tools / nautilus2claws-mail.sh
1 #!/usr/bin/env bash
2
3 # nautilus2claws-mail.sh
4 # Copyright 2004 Reza Pakdel <hrpakdel@cpsc.ucalgary.ca>
5
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 3
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, USA.
20
21 # This script will recursively attach a number of selected 
22 # files/directories from Nautilus to a new blank e-mail.
23
24 # Authors: Reza Pakdel <hrpakdel@cpsc.ucalgary.ca>
25 #                  Stephan Sachse <white@teg-clan.de>
26 #
27 # Fixes:
28 #               Stephan Sachse  :  files/directorys with whitspaces
29
30
31 SELECTED_PATHS="${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}"
32 NB_SELECTED_PATHS=`echo -n "${SELECTED_PATHS}" | wc -l | awk '{print $1}'`
33
34 ATTACHMENTS=""
35
36 for ((i=${NB_SELECTED_PATHS}; i>0; i--)) ; do
37         CURRENT_PATH=`echo -n "${SELECTED_PATHS}" | head -n${i} | tail -n1`
38         if test -d "${CURRENT_PATH}" ; then
39                 FILES_FOUND=`find "${CURRENT_PATH}" -type f`
40                 NB_FILES_FOUND=`echo "${FILES_FOUND}" | wc -l | awk '{print $1}'`
41                 for ((j=${NB_FILES_FOUND}; j>0; j--)) ; do
42                         CURRENT_FILE=`echo "${FILES_FOUND}" | head -n${j} | tail -n1`
43                         ATTACHMENTS="${ATTACHMENTS} \"${CURRENT_FILE}\""
44                 done
45         else
46                 ATTACHMENTS="${ATTACHMENTS} \"${CURRENT_PATH}\""
47         fi
48 done
49
50 echo "-----------"
51 echo ${ATTACHMENTS}
52
53 eval "claws-mail --compose --attach ${ATTACHMENTS}"
54