If I understand your intentions, you create directories whose names are numbers, and move 3000 files into each of them.
You script looks OK except this part will be executed for each file:
Code:
mv $f $dir
mv $dir /pwd/header2018/
After the first file $f, $dir won't exist in this directory and you will get 2999 error messages.
Fix that and test it with a few thousand dummy files in a dummy directory.
Personally, I think a program is more readable when you use
if instead of the
&& construct, but that's just a style question.