ls -1 | sort -V > txt_list
and
cat txt_list
gives
ASOFJ.txt
BJWIF.txt
CWORI.txt
...
I want to mkdir
with suffix in ascending order like folder_1
, folder_2
, folder_3
and mv ASOFJ.txt folder_1
, mv BJWIF.txt folder_2
, mv CWORI.txt folder_3
I have tried
num=0 ; while read p ; do ( num=$(expr $num + 1) && mkdir "folder_"$num && mv $p "folder_"$num ) ; done < txt_list
But it didn't work.
Do you have any idea on a one-liner that executes the above?
Thanks.
let c=0; for i in $('ls'); do c=$((c+1)); mkdir -p folder_$c; mv $i folder_$c; done
This should do it, I think.
Explanation:
c
c
c