From 3ff17203ae9f4f682861894e51c03d58ffe6825a Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Mar 08 2011 17:03:05 +0000 Subject: Rename identity_renderGroupByType to identity_groupSimilarFiles. --- diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_groupSimilarFiles.sh b/Scripts/Bash/Cli/Functions/Identity/identity_groupSimilarFiles.sh new file mode 100755 index 0000000..ed555be --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/identity_groupSimilarFiles.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# identity_groupSimilarFiles.sh -- This function provides +# post-rendition action to group files inside directories named as +# their file extensions. For example: if the current file is a .png +# file, it is moved inside a Png/ directory; if the current file is a +# .jpg file, it is stored inside a Jpg/ directory, and so on. +# +# For this function to work correctly, you need to specify which file +# type you want to group. This is done in the post-rendition ACTIONS +# array inside the appropriate `render.conf.sh' pre-configuration +# script. This function cannot be used as last-rendition action. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_groupSimilarFiles { + + local SOURCE='' + local TARGET='' + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + local FORMATS=$(identity_getConfigOption "$ACTION" '2-') + + for FORMAT in $FORMATS;do + + # Redifine source file we want to move. + SOURCE=${FILE}.${FORMAT} + + # Define target directory where source file will be moved + # into. + TARGET=$(dirname "$FILE")/$(cli_getRepoName "$FORMAT" 'd') + + # Check existence of source file. + cli_checkFiles $SOURCE 'f' + + # Check existence of target directory. + if [[ ! -d $TARGET ]];then + mkdir -p $TARGET + fi + + # Redifine file path to add file and its type. + TARGET=${TARGET}/$(cli_getRepoName "$FILE" 'f').${FORMAT} + + # Move file into its final location. + cli_printMessage "$TARGET" 'AsMovedToLine' + mv ${SOURCE} ${TARGET} + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderGroupByType.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderGroupByType.sh deleted file mode 100755 index 0f03e44..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderGroupByType.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# identity_renderGroupByTypes.sh -- This function provides -# post-rendition action to group files inside directories named as -# their file extensions. For example: if the current file is a .png -# file, it is moved inside a Png/ directory; if the current file is a -# .jpg file, it is stored inside a Jpg/ directory, and so on. -# -# For this function to work correctly, you need to specify which file -# type you want to group. This is done in the post-rendition ACTIONS -# array inside the appropriate `render.conf.sh' pre-configuration -# script. This function cannot be used as last-rendition action. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderGroupByType { - - local SOURCE='' - local TARGET='' - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - local FORMATS=$(identity_getConfigOption "$ACTION" '2-') - - for FORMAT in $FORMATS;do - - # Redifine source file we want to move. - SOURCE=${FILE}.${FORMAT} - - # Define target directory where source file will be moved - # into. - TARGET=$(dirname "$FILE")/$(cli_getRepoName "$FORMAT" 'd') - - # Check existence of source file. - cli_checkFiles $SOURCE 'f' - - # Check existence of target directory. - if [[ ! -d $TARGET ]];then - mkdir -p $TARGET - fi - - # Redifine file path to add file and its type. - TARGET=${TARGET}/$(cli_getRepoName "$FILE" 'f').${FORMAT} - - # Move file into its final location. - cli_printMessage "$TARGET" 'AsMovedToLine' - mv ${SOURCE} ${TARGET} - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh index bfc0038..7e77c16 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderLastActions.sh @@ -42,7 +42,7 @@ function identity_renderLastActions { case "${ACTION}" in groupByType:* ) - identity_renderGroupByType + identity_groupSimilarFiles ;; esac diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh index f10941c..53dd99f 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderPostActions.sh @@ -37,7 +37,7 @@ function identity_renderPostActions { ;; groupByFormat:* ) - identity_renderGroupByType + identity_groupSimilarFiles ;; esac