With a little for loop and some magical sed, I was able to figure out a quick line to help me
rename all the files in a specific folder that have characters I don’t want there.

This line will look at all the .jpg’s in the current directory and rename them taking out any instance of “( ” and replacing it with ” – “. I’m sure you can figure out how to tailor this to your liking by editing the type of file extension and putting in your own sed statements.

<pre class="wp-code-highlight prettyprint">for file in *.jpg; do mv "$file" "$(echo "$file" | sed s/\ \(/\ -\ /g)"; done</pre><p></p>

Nice huh.?

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview