Linux, rename files with bash 'no such file or directory' error
<p>I'm trying to add a prefix to all files that are not <code>.sh</code> files in the current directory, and all subdirectories, with <code>bash</code> using <code>find</code>.</p>

<p>The problem is that I get an error:</p>

<pre><code>mv: cannot move './test.txt' to 'PRE_./test.txt': No such file or directory
</code></pre>

<p>My one-liner is:</p>

<pre><code>find -type f ! -name "*.sh" -exec sh -c 'mv "{}" PRE_"{}"' _ {} \;
</code></pre>

<p>I tried <code>xargs</code> with <code>rename</code>, too:</p>

<pre><code>find -type f ! -name "*.sh" -print0 | xargs -0 rename 's/(.*)$/PRE_$1/'
</code></pre>

<p>But I got the same error.
What's wrong?
Thanks in advance!</p>