xdotcommer
xdotcommer

Reputation: 48

Linux copying selected files from directories and naming them after the directory name

lets say I have (linux/unix)

/directory/1/file.wmv
/directory/2/file.wmv
/directory/3/file.wmv

I want to copy these .wmv files into a single directory /example/ with files named after directory names they were in like so 1.wmv, 2.wmv, 3.wmv,

Upvotes: 0

Views: 287

Answers (1)

Chakalaka
Chakalaka

Reputation: 2827

for i in {1..10}
do
    cp /directory/$i/file.wmv /example/$i.wmv
done

Upvotes: 1

Related Questions