bash script to copy rename files
Hi I am trying to right a bash script that will scan folders recursivly for file types .tbn and copy that file and rename it to cover.jpg within same directory.
So far the following script finds files but copys and renames file to where i run the cript from not where the original file is. Not understanding the the basic syntax is a big handicap have done extensive searches but cant quite find what i am looking for. for file in **/*.tbn do cp "${file}" cover.jpg done |
I think something following should do the trick
find ./ -name <filename.extension> | xargs mv <suit your needs> |
Code:
cp "${file}" cover.jpg Code:
#!/bin/bash Code:
find . -name \*.tbn -execdir cp {} cover.jpg \; |
Many thanks
Quote:
Thank you all for your fast replies this bugging me for 3 hours |
No need for dirname, an external command. Just use built-in parameter substitution.
Code:
cp "$file" "${file%/*}"/cover.jpg I think the find version used above is a better choice though. |
All times are GMT -5. The time now is 05:29 AM. |