0

I am writing a script to change size of svg images. Here is what I am trying

#!/bin/bash
for file in *
do
  rsvg-convert "$file" -w 160 -h 160 -f svg -o `echo $i | sed -e 's/svg$/new.svg/'`
done

But this is not working.

1 Answer 1

2

Use bash substitition directly (${file%.svg} will remvoe .svg from the end of file variable):

#!/bin/bash
mkdir -p folder
for file in *
do
  rsvg-convert "$file" -w 160 -h 160 -f svg -o folder/${file%.svg}new.svg 
done
Sign up to request clarification or add additional context in comments.

4 Comments

^ for a solution with Bash substitution !
Thanks for your prompt answer but I want same file names saved in different folder
@Sid It would be good to mention that in the question, I added that the answer
@krzyk apologies for not being clear. I tried to convey it in question heading but should have explained it in description also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.