<div dir="ltr">2008/8/26 Rashkae <span dir="ltr"><<a href="mailto:ubuntu@tigershaunt.com">ubuntu@tigershaunt.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">Johnny Rosenberg wrote:<br>
> 2008/8/26 Johnny Rosenberg <<a href="mailto:gurus.knugum@gmail.com">gurus.knugum@gmail.com</a>><br>
><br>
>> 2008/8/25 Ulf Rompe <<a href="mailto:Ulf.Rompe@icem.com">Ulf.Rompe@icem.com</a>><br>
>><br>
>>> Sorry all for the previous, empty post.<br>
>>><br>
>>> On Mo, 2008-08-25 at 16:00 +0200, Johnny Rosenberg wrote:<br>
>>>> Since there is a serious bug in Nautilus, that adds the very<br>
>>>> unnecessary text "Link to " to a link created with Ctrl+Shift<br>
>>>> +Drag&Drop,<br>
>>> I don't think it's a serious bug. I would call it bad design. :-)<br>
>>><br>
>>>> rename -v 's/Link to //' *<br>
>>>><br>
>>>> However, there doesn't seem to be an option for recursivity built in<br>
>>>> to that command. I am not good with scripts, but I am sure there is a<br>
>>>> way around that.<br>
>>> find . -type l -print0 | xargs -0 rename -v 's/Link to //'<br>
>>><br>
>>> [x] ulf<br>
>>><br>
</div>>>> Tack sÃ¥ mycket! Har inte testat Ã¤n, men det ser ut som en vettigare<br>
>> lösning Ã¤n den jag lyckades komma fram till via vild sökning pÃ¥ nätet:<br>
>> find . -name "Länk till "* -exec rename -v "s/Länk till //" {} \;<br>
<div class="Ih2E3d">>> My guess is that your solution might be a bit faster. IN my solution, both<br>
</div>>> find and rename look for the same thing, kind of…<br>
<div class="Ih2E3d">>> As everyone can see, I'm a bash beginner but I learn all the time. I think<br>
>> that my new knowledge of xargs will make me able to do things that I<br>
>> couldn't before! Thanks again!<br>
>> J.R.<br>
>><br>
> Ooops, sorry for the Swedish line there. For a strange reason I changed to<br>
</div>> English after that, I don't really know why… here's the translation for the<br>
<div class="Ih2E3d">> first line anyway:<br>
><br>
> Thanks! haven't tried it yet, but it makes more sense than the solution I<br>
> came up with after some wild searching on the web:<br>
><br>
</div>> find… and so on.<br>
<div class="Ih2E3d">><br>
> By the way, after some more thinking, I combined your solution with mine and<br>
> came up with the following:<br>
><br>
</div>> find . -type l -exec rename -v "s/Länk till //" {} \;<br>
<div class="Ih2E3d">><br>
> This way it's all done without piping, at least that is what it looks like.<br>
> It would be interesting to hear from you (and others) about advantages and<br>
> disadvantages with this line compared to other ideas. The only advantage I<br>
> can think of is that it's less to type, but I will make an alias for it<br>
> anyway, so that doesn't matter much, more than my alias file will be a few<br>
</div>> bytes smaller…<br>
><br>
> Anf I didn't try my last suggestion yet, maybe it doesn't work… ha ha ha<br>
><br>
<br>
That should work.. I can't remember if I also had to esape the { }<br>
characters in bash, or just the ;....<br>
<br>
However, the command would be much more efficient if find was only<br>
returning filenames that start with "Link To", they way your command<br>
runs now, *every* file gets passed to rename.  This would work, but is<br>
wasteful, since rename then fires up perl and run a regexp that will<br>
only fail.<br>
find . -type l -name "Link to*" -exec rename -v "s/Länk till //" {} \;<br>
<div><div class="Wj3C7c"></div></div></blockquote><div></div><div>That is just about the same as my first idea, (except that I had -name but not -type) after collecting as much info as possible from the web.</div><div>However, someone told me today that this will work (I write this one in English since something on the way between me you guys doesn't use UTF-8, so the Swedish characters gets "distorted" anyway):</div>
<div>find . -type l -exec rename -v "s/Link to //" {} +</div><div></div><div>The + seems to make find -exec work like find | xargs, sort of.</div><div></div><div>But to sum this up, I guess that the following would be a good combination of all ideas so far:</div>
<div>find . -type l -name "Link to *" -exec rename -v "s/Link to //" {} +</div><div></div><div>On the other hand, I can probably assume that everything that can be found that's not a link, does not start with "Link to " anyway, so in most cases the type -l is very unnecessary…</div>
<div>In that case, that makes this the best solution, I'd guess:</div><div>find . -name "Link to *" -exec rename -v "s/Link to //" {} +</div><div>(same as your suggestion, but with "+" instead of "\;".</div>
<div></div><div>There also seems to be a -execdir option, but I didn't understand exactly when or why I'd use it (I sometimes have some minor difficulties understanding English in manuals etc).</div><div></div><div>
J.R.</div></div>