I am new to this. I have many files from b_ap00 to b_ap80, and I need to move them to folder 00 to 80 respectively, where b_ap00 is in folder 00, b_ap01 is in folder 01.
On top of this, I need to rename the file once they are inside the folder to b_ot, and subsequently run it (ifort -o b-i.x b_ot followed by ./b-i.x)
Could someone please guide me along? I managed to create the folders somehow but moving them in has problems.
for i in {0..80}
do
name=$(printf "%02d" $i)
file_name="b_ap$name"
mv $file_name /$name
mv /$name/$file_name #what you want to do
#do your operations here
done
Thank you so much. But I have this error:
mv: cannot create directory `/080': Permission denied
mv: missing destination file operand after `/80/b_ap80 #for all my files from 00
Basically this is what I did:
split -d -l 98 a01 b_ap
printf "%03d\n" $(seq 0 80) | xargs -I{} mkdir {}
for i in {0..80}
do
name=$(printf "%03d" $i)
file_name="$name"
mv $file_name /$name
mv /$name/$file_name/ #what you want to do
#do your operations here
done