Need Help with simple UNIX Script
#1
...or I suspect it will be easy for you folks. I'm simply trying to do the following:

Go through all my TV folders and do two copy/renames within each folder:
copy all folder.jpg to banner.jpg
copy all poster.jpg to folder.jpg

I've trying various different things but am struggling, likely because my folders have spaced in them (e.g. /mnt/user/My TV/Family TV/Dinosaur Train).

The script I've ben using are:
find . -name folder.jpg -print0 | xargs -0 -i cp --preserve ./{} ./banner.jpg
find . -name poster.jpg -print0 | xargs -0 -i cp --preserve ./{} ./folder.jpg

but they fail when run from the parent directory. Just grabs the first one it finds and drops it in the parent directory rather than recursively making the copies in each directory.

Here are the internet samples I was going off, but they're not exactly what I was looking for:

find . -name '.AppleDouble' -printf '"%p"\n' | xargs rm -Rf
find /originalPath/ -name *.mp3 -print0 | xargs -0 -i cp ./{} /destinationPath/

I'm sure this would be a snap for you UNIX gurus. Much appreciate any help!
Reply
#2
Code:
#!/bin/bash

IFS=$'\n'
for i in `find $1 -type d`; do
  echo Processing $i
  test -f "$i/folder.jpg" && cp "$i/folder.jpg" "$i/banner.jpg"
  test -f "$i/poster.jpg" && cp "$i/poster.jpg" "$i/folder.jpg"
done

$1 = dir to process.
Reply
#3
spiff Wrote:
Code:
#!/bin/bash

IFS=$'\n'
for i in `find $1 -type d`; do
  echo Processing $i
  test -f "$i/folder.jpg" && cp "$i/folder.jpg" "$i/banner.jpg"
  test -f "$i/poster.jpg" && cp "$i/poster.jpg" "$i/folder.jpg"
done

$1 = dir to process.

Thanks bud!
Reply
#4
ZestyChicken Wrote:Thanks bud!

So I created two scripts from this:

BannersRule.sh:
#!/bin/bash

IFS=$'\n'
for i in `find "mnt/user/My TV" -type d`; do
echo Processing $i
test -f "$i/banner.jpg" && cp "$i/banner.jpg" "$i/folder.jpg"
done

PostersRule.sh:
#!/bin/bash

IFS=$'\n'
for i in `find "mnt/user/My TV" -type d`; do
echo Processing $i
test -f "$i/banner.jpg" && cp "$i/banner.jpg" "$i/folder.jpg"
done

These allow me to toggle back and forth between posters and banners for the main TV show jpg. Then I just have to delete my thumbnails cache (actually I left music folder alone), delete the textures6.db, rescrape my video database and voila, everything is what I want.

What I would love is a way to update the thumbnails cache automatically but that looks to be quite a difficult undertaking...
Reply

Logout Mark Read Team Forum Stats Members Help
Need Help with simple UNIX Script0