Re: The rename command…



Johnny Rosenberg wrote:
2008/8/26 Johnny Rosenberg <gurus.knugum@xxxxxxxxx>

2008/8/25 Ulf Rompe <Ulf.Rompe@xxxxxxxx>

Sorry all for the previous, empty post.

On Mo, 2008-08-25 at 16:00 +0200, Johnny Rosenberg wrote:
Since there is a serious bug in Nautilus, that adds the very
unnecessary text "Link to " to a link created with Ctrl+Shift
+Drag&Drop,
I don't think it's a serious bug. I would call it bad design. :-)

rename -v 's/Link to //' *

However, there doesn't seem to be an option for recursivity built in
to that command. I am not good with scripts, but I am sure there is a
way around that.
find . -type l -print0 | xargs -0 rename -v 's/Link to //'

[x] ulf

Tack så mycket! Har inte testat än, men det ser ut som en vettigare
lösning än den jag lyckades komma fram till via vild sökning på nätet:
find . -name "Länk till "* -exec rename -v "s/Länk till //" {} \;
My guess is that your solution might be a bit faster. IN my solution, both
find and rename look for the same thing, kind of…
As everyone can see, I'm a bash beginner but I learn all the time. I think
that my new knowledge of xargs will make me able to do things that I
couldn't before! Thanks again!
J.R.

Ooops, sorry for the Swedish line there. For a strange reason I changed to
English after that, I don't really know why… here's the translation for the
first line anyway:

Thanks! haven't tried it yet, but it makes more sense than the solution I
came up with after some wild searching on the web:

find… and so on.

By the way, after some more thinking, I combined your solution with mine and
came up with the following:

find . -type l -exec rename -v "s/Länk till //" {} \;

This way it's all done without piping, at least that is what it looks like.
It would be interesting to hear from you (and others) about advantages and
disadvantages with this line compared to other ideas. The only advantage I
can think of is that it's less to type, but I will make an alias for it
anyway, so that doesn't matter much, more than my alias file will be a few
bytes smaller…

Anf I didn't try my last suggestion yet, maybe it doesn't work… ha ha ha


That should work.. I can't remember if I also had to esape the { }
characters in bash, or just the ;....

However, the command would be much more efficient if find was only
returning filenames that start with "Link To", they way your command
runs now, *every* file gets passed to rename. This would work, but is
wasteful, since rename then fires up perl and run a regexp that will
only fail.
find . -type l -name "Link to*" -exec rename -v "s/Länk till //" {} \;

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


Relevant Pages

  • Re: Great SWT Program
    ... a good tutorial on Unix CLI tools? ... command there, ... then rename everything in the search scope with the CLI, ... I'd have to boot up a Windows system and try stuff, ...
    (comp.lang.java.programmer)
  • Re: How To Make index.shtml As A Home Page?
    ... is the correct command, but will only be effective if AllowOverride All ... overridden (provided AllowOverride is set) using .htaccess as you have done. ... > DirectoryIndex index.shtml index.html index.htm index.php ... you should be able to open your online web in FrontPage and rename ...
    (microsoft.public.frontpage.client)
  • =?UTF-8?Q?Re:_The_rename_command=E2=80=A6?=
    ... the command would be much more efficient if find was only ... *every* file gets passed to rename. ... the Swedish characters gets "distorted" anyway): ... understanding English in manuals etc). ...
    (Ubuntu)
  • Re: The rename =?windows-1252?Q?command=85?=
    ... From the very beginning of Linux the Windows users had to ... learn that rename is not part of the commands. ... When first starting to use computers, if we do not count the very first ... I accidently found that rename command, ...
    (Ubuntu)
  • Re: Cant Rename a File Using WinXP Command Prompt!!!
    ... It needs to be given a shorter name so that it can be ... I cannot rename it using the Command Prompt and the ... The old filename in question contains the following symbols as ...
    (microsoft.public.windowsxp.help_and_support)