Enrico Pirani
Enrico Pirani

Reputation: 1507

Moving multiple files in different folder

I need make multiple folder having the name from file without extension with this command

for i in *.avi; do mkdir "${i%.*}"; done

I don't know how to mv the related file in the folder made...

Thanks for any help

Thanks. Let's say I want to do a general script to record on Textexpander which ask me for the file extension a sort of this :

echo "Type the suffix of the file follewe by enter:"
read ext
for i in *.ext
do
    mkdir "${i%.ext}"
    mv "$i" "${i%.ext}"
done

But this is not working.

Upvotes: 0

Views: 68

Answers (1)

dogbane
dogbane

Reputation: 274612

Use the mv command:

for i in *.avi
do 
    mkdir "${i%.*}"
    mv "$i" "${i%.*}"
done

Upvotes: 3

Related Questions