Re: need help with bash command
tôba wrote:
> Hello,
>
> Can you help me with a bash command?
> I a directory, I want to extract with a command line for jpg name files.
> I have a lot of:
>
> icon_3620_0_1.jpg
> icon_3616_0_1.jpg
> icon_3563_0_1.jpg
>
> I want to extract the number betwen icon_*_0_1.jpg AND I want to use
> the entire filename too in the same command.
>
> The goal is to create a directory called 3620 and move the
> icon_3620_0_1.jpg file into this directory.
>
I am sure somebody would have solved this already, but here what I do in
such a situation:
#in the directory with the images. This will create dirs based on the
#numbers in the image filenames and move that file to its corresponding
#directory
for f in icon_????_0_1.jpg; do
num=`echo $f | sed -e 's/icon_\([0-9]*\)_0_1\.jpg/\1/'`; #get number
mkdir ${num};
mv $f ${num};
done
--
Please reply to this list only. I read this list on its corresponding
newsgroup on gmane.org. Replies sent to my email address are just
filtered to a folder in my mailbox and get periodically deleted without
ever having been read.
Reply to: