Reputation: 657
I have a script that converts SVG files into PNG using inkscape. However, the converted files are placed in the top directory where the script is located. I want the converted files to be placed in its sub directory.
The top-level directory looks like this:
folderA
|---file1.svg
|---file2.svg
|---file3.svg
folderB
|---file4.svg
|---file5.svg
|---file6.svg
svg2png.sh
After running the script, I want the PNG files to be located to its subdirectory like this:
folderA
|---file1.svg
|---file1.png
|---file2.svg
|---file2.png
|---file3.svg
|---file3.png
folderB
|---file4.svg
|---file4.png
|---file5.svg
|---file5.png
|---file6.svg
|---file6.png
svg2png.sh
Not like this:
file1.png
file2.png
file3.png
file4.png
file5.png
file6.png
folderA
|---file1.svg
|---file2.svg
|---file3.svg
folderB
|---file4.svg
|---file5.svg
|---file6.svg
svg2png.sh
Here is the svg2png.sh
#/bin/sh
find . -name \*.svg -exec sh -c 'inkscape -z -e $(basename {} .svg).png {}' \;
Here is the updated svg2png.sh as provided by @ anishsane:
#/bin/sh
find . -name \*.svg -execdir sh -c 'inkscape -z -e $(basename {} .svg).png {}' \;
Upvotes: 2
Views: 55
Reputation: 20980
Adding it as answer. This should help you:
find . -name \*.svg -execdir sh -c 'inkscape -z -e $(basename {} .svg).png {}' \;
Upvotes: 1