Hello all,
I would appreciate any help to write a script. I have folder A which contains over 30 thousands xml files, I would like create multiple folders and move those files (500 in each folders).
Thank you
Hello all,
I would appreciate any help to write a script. I have folder A which contains over 30 thousands xml files, I would like create multiple folders and move those files (500 in each folders).
Thank you
Here is a bash script:
#!/bin/bash
c=1; d=1; mkdir -p dir_${d}
for xml_file in *.xml
do
if [ $c -eq 501 ]
then
d=$(( d + 1 )); c=0; mkdir -p dir_${d}
fi
echo mv "$xml_file" dir_${d}/
c=$(( c + 1 ))
done
Note: Remove the highlighted echo if the output looks good.