diff --git a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh index 0259f96..2af7c88 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh @@ -102,7 +102,7 @@ function render_doIdentityGroupByType { PATTERNS[0]=$(echo "$FORMATS" | sed 's! !|!g') # Define pattern for directories. - PATTERNS[1]=$(echo $(for i in $FORMATS; do cli_getRepoName $i 'd'; done) | sed 's! !|!g') + PATTERNS[1]=$(echo $(for i in $FORMATS; do cli_getRepoName "$i" 'd'; done) | sed 's! !|!g') # Define pattern for path. The path pattern combines both file # extension and directories patterns. This pattern is what we @@ -134,18 +134,23 @@ function render_doIdentityGroupByType { for FORMAT in $FORMATS;do - # Redifine file path to add file type directory + # Redifine source file we want to move. SOURCE=${FILE}.${FORMAT} - TARGET=$(dirname $FILE)/$(cli_getRepoName "$FORMAT" 'd') + + # 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. - cli_checkFiles $TARGET 'd' + if [[ ! -d $TARGET ]];then + mkdir -p $TARGET + fi # Redifine file path to add file and its type. - TARGET=${TARGET}/$(basename $FILE).${FORMAT} + TARGET=${TARGET}/$(cli_getRepoName "$FILE" 'f').${FORMAT} # Move file into its final location. cli_printMessage "$TARGET" 'AsMovedToLine'