Problem resolved,by two ways. the first one:
using a for loop:
#!/bin/bash
pattern1=`zenity --entry --entry-text='replace'`
if [ "$?" -eq 1 ]
then
exit
fi
pattern2=`zenity --entry --entry-text='by'`
if [ "$?" -eq 1 ]
then
exit
fi
for file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
rename "s/$motif1/$motif2/g" "$file"
done
zenity --info --text="Done"
the second : using a while loop:
#!/bin/bash
pattern1=`zenity --entry --entry-text='replace'`
if [ "$?" -eq 1 ]
then
exit
fi
pattern2=`zenity --entry --entry-text='by'`
if [ "$?" -eq 1 ]
then
exit
fi
echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS | while read 'file'
do
rename "s/$motif1/$motif2/g" "$file"
done
zenity --info --text="Done"
the question now is why I have to do that
and the answer is because $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS is a sequence
even if one file is selected we will find in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS the file selected path and a separator character
you can see that by using this commande:(add it to the script)
zenity --entry --entry-text="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
I hope that this can be usefull for someone
Inspired by that