[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: shell scripts and spaces in file/folder names



Hello,

Well, I know how to get this to work now.
I'll have a look at perl and/or python too

Thank you for the recommendations and the many ways to
handle those files :-)

Joris


--- Ron Johnson <ron.l.johnson@cox.net> wrote:
...

> 
> Yet another method:
> 
>   $ touch "foo bar"
>   $ touch "foo snafu"
>   $ for f in "`ls -1 | grep ' '`";
>   > do
>   >     echo "$f"
>   > done
>   foo bar
>   foo snafu
> 
> Note the *2* pair of double quotes, and the pair of
> "back quotes".
> 
> However, you should learn perl or python.  I really
> like python, but
> perl is ubiquitous...
> 
> Here's a script I use to change files with spaces to
> dashes.
> 
> 
>   #!/usr/bin/perl
>   use warnings;
>   use strict;
>   my $fn;
>   my $nn;
>   chdir ("/dir/with/spaces");
>   opendir(DIRHANDLE,".");
>   while ($fn = readdir(DIRHANDLE))
>   {
>       if ($fn =~ / /)
>       {
>           $nn = $fn;
>           $nn =~ s/ /-/g;
>           rename("$fn", $nn);
>       }
>   }
>   closedir(DIRHANDLE);
> 
> Gurus can do it in far fewer, but more cryptic
> lines, but I like
> this way.
> 
> -- 
>
+-----------------------------------------------------------+
> | Ron Johnson, Jr.     Home: ron.l.johnson@cox.net  
>        |
> | Jefferson, LA  USA  
> http://members.cox.net/ron.l.johnson |
> |                                                   
>        |
> | An ad currently being run by the NEA (the US's
> biggest    |
> | public school TEACHERS UNION) asks a teenager if
> he can   |
> | find sodium and *chloride* in the periodic table
> of the   |
> | elements.                                         
>        |
> | And they wonder why people think public schools
> suck...   |
>
+-----------------------------------------------------------+
> 
> 
> -- 
> To UNSUBSCRIBE, email to
> debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org
> 


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com



Reply to: