Bash move and rename by parsing the output of find

خرید بک لینک

I have nested directories of pdf files and I would like to extract them to a higher level directory renaming them as follows:

My files are something like:

./path1/pathA/fileI.pdf

./path1/pathB/fileII.pdf

I want to achieve:

./path1_pathA_fileI.pdf

./path1_pathB_fileII.pdf

I know I can make a list of the files by doing

find . -type f -name "*.pdf"

And I can imagine a solution using

find . -type f -name "*.pdf" | mv -t ...

But I don't know how to fill in the ... because I don't understand parsing and variable assignment in bash. How does one split the path at the '/' and form a new path and file name as above?

Many thanks in advance!

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 215 تاريخ: چهارشنبه 9 تير 1395 ساعت: 10:33

صفحه بندی