nautilus2sylpheed.sh 1.8 KB

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