I would like to seek help regarding the code of creating folders and moving files to it. I want to create folders, place the files ending with specific extension and only certain number of files in each folder. For example, I have 10 text files, create 5 folders, each folder having two files. (Files have names like 1.txt, 2.txt , .... , 10.txt. So 1.txt and 2.txt should be in folder 1, 3.txt and 4.txt in folder 2 and so on.
My code looks like this:
end=2
sta=1
for i in {1..5}
do
mkdir "$i"
for file in *.txt:
do
mv "{$sta..$end}.txt" "$i"
done
end=$((end+2))
begin=$((begin+2))
done
It should be similar to it but I have an error,"mv: cannot stat '{1..10}.txt': No such file or directory".
I know it will be a simple change but couldn't figure it out. I have gone through the previous questions but couldn't sort my code.
Thanks!