Skip to content

Instantly share code, notes, and snippets.

@boina-n
Last active April 7, 2018 10:43
Show Gist options
  • Save boina-n/15f2db4ed074ae1210878795e10ea195 to your computer and use it in GitHub Desktop.
Save boina-n/15f2db4ed074ae1210878795e10ea195 to your computer and use it in GitHub Desktop.
rename list of file based on the separator "-" and have the extension .xml
#!/bin/bash
if [ "$#" != 2 ] ; then
echo 'donne des arguments mooonnn !!!!'
exit 0
fi
src=$1
dst=$2
list=$(ls $src)
mkdir -p $dst
echo $list
for i in $list
do
n=$(echo $i | awk -F '-' '{print $1".xml"}')
if [ -f $dst/$n ]; then
echo "un fichier $dst/$n existe déja"
else
mv $src/$i $dst/$n
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment