Created
February 5, 2021 13:03
-
-
Save WillCQ97/3a624ce3eb51deaa7225c8b7e227746c to your computer and use it in GitHub Desktop.
Move arquivos aleatóriamente para pastas numeradas, de acordo com o máximo de arquivos definidos para cada pasta.
This file contains 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 | |
# Autor: willcq | |
# Cria diretórios e randomicamente move arquivos para ele. | |
CONT=0 | |
VALOR=1 | |
MAX_ARQ=20 | |
ls | sort -R | while read -r file ; do | |
if [ $CONT -eq 0 ] | |
then | |
echo "Criando o diretório dir_$VALOR" | |
mkdir dir_$VALOR | |
fi | |
printf 'Movendo arquivo '"'%s'"'\n' "$file" | |
mv "$file" dir_$VALOR | |
if [ $CONT -eq $MAX_ARQ ] | |
then | |
CONT=0 | |
VALOR=$[ $VALOR + 1 ] | |
else | |
CONT=$[ $CONT + 1 ] | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment