Last active
April 7, 2018 10:43
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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