Oui c'est possible, exemple :
Mon nom de fichier de test :
# TEST=test.1.2.3.4.ext
Pour affiché l'extension :
# echo ${TEST##*.}
ext
Pour le nom de fichier :
# echo ${TEST%.*}
test.1.2.3.4
Pour mixé le tous :
# echo ${TEST%.*}-${USER}.${TEST##*.}
test.1.2.3.4-xataz.ext
Ce qui donnerais pour le code complet (Pas tester, mais normalement c'est bon) :
#!/bin/bash
NAME=$1
FOLDER=$2
## Check if folder
file "$FOLDER/$NAME" | grep "directory" > /dev/null 2>&1
if [ $? -eq 0 ]; then
FOLDER="$FOLDER"/"$NAME"
NB_FILE=$(ls -1 "$FOLDER" | grep -Ev '.txt|.nfo|.md' | wc -l)
if [ $NB_FILE -gt 1 ]; then
TMP="/tmp/file.tmp"
ls -1 | grep -Ev '.txt|.nfo|.md' > $TMP
while read FILE; do
plowup uptobox $FOLDER/$FILE:${FILE%.*}-${USER}.${FILE##*.} &
done < $TMP
else
FILE=$(ls -1 "$FOLDER" | grep -Ev '.txt|.nfo|.md')
plowup uptobox $FOLDER/$FILE:${FILE%.*}-${USER}.${FILE##*.} &
fi
else
FILE=$NAME
plowup uptobox $FOLDER/$FILE:${FILE%.*}-${USER}.${FILE##*.} &
fi