Language:
switch to room list switch to menu My folders
Go to page: First ... 48 49 50 51 [52] 53 54 55 56 ... Last
[#] Thu Sep 24 2009 12:01:34 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

We have not had such experience. Off hand I'd say we have a hardware failre of some kind on some important box every 2-3 months.

[#] Sat Jan 09 2010 22:07:44 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I have a good oldfashioned unix question.
I would like to get a file list of a directory tree. I'd like the files in each directory to be sorted in alphabetical order, and I'd like the directories themselves to be sorted backwards. That I can live without, but it's important that each file in a given directory be ordered alphabetically.
The goal here that I can feed this list to somethign that copies files, the endgoal being to make a directory tree full of mp3s that will play in order on my fancy dancy new car stereo.
Every unix toy I think of either just uses shell expansion or doesn't sort at all.
ls would work but it doesn't list full paths that I can use in a copy or tar or cpio.
find doesn't seem to sort.
Anybody got a slick and easy shell way of doing this?

[#] Sun Jan 10 2010 05:52:34 EST from davew @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

 

Sat Jan 09 2010 10:07:44 PM EST from Ford II @ Uncensored
I have a good oldfashioned unix question.
I would like to get a file list of a directory tree. I'd like the files in each directory to be sorted in alphabetical order, and I'd like the directories themselves to be sorted backwards. That I can live without, but it's important that each file in a given directory be ordered alphabetically.
The goal here that I can feed this list to somethign that copies files, the endgoal being to make a directory tree full of mp3s that will play in order on my fancy dancy new car stereo.
Every unix toy I think of either just uses shell expansion or doesn't sort at all.
ls would work but it doesn't list full paths that I can use in a copy or tar or cpio.
find doesn't seem to sort.
Anybody got a slick and easy shell way of doing this?

I guess you'll need a script something along the lines of

PWD=`pwd`

for i in `ls -1` do

echo "$PWD/$i"

done

that'll prepend the current dir to each line of ls output.

To enhance that you can then use test -d and test -f to filter out dirs and real files.



[#] Sun Jan 10 2010 06:53:08 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

you could do find -type d |sort



[#] Sun Jan 10 2010 06:54:01 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

ah, and feed that into

tar -cO |(cd /where-to-pot; tar -xf - )



[#] Sun Jan 10 2010 21:43:58 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

you could do find -type d |sort

yeah, I realize, I sort that, then pass it to a script that lists that directory in sorted order. that should do it.

[#] Mon Jan 11 2010 11:32:09 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Or just do it in perl.

[#] Mon Jan 11 2010 12:56:08 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Anybody got a slick and easy shell way of doing this?

Why do the directories need to be sorted backwards? If you omit that requirement, you can just do

find . -print | sort

Very easy.

[#] Mon Jan 11 2010 15:40:48 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Jan 11 2010 11:32am from Peter Pulse @uncnsrd
Or just do it in perl.

You wouldn't be trying to goad me into a seizure would you?

I found at one point that anything a normal person might do in perl, I can do in awk. So if I had to, I'd use awk, but I thought there must be some combination of shell commands that could do it.

[#] Mon Jan 11 2010 15:41:25 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Why do the directories need to be sorted backwards? If you omit that

requirement, you can just do

Because they're in number order and I want the newest at the top.

[#] Mon Jan 11 2010 16:35:46 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I -was- trolling you ;)

..and it worked..

[#] Mon Jan 11 2010 16:38:25 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

But seriously, funny you should mention awk, because anything you can do in awk, you can do in perl. But in perl, you can do:

if(-d) {
# it's a directory, do the shit you want to do with a directory
} else {
# it's a file, do the file shit
}

[#] Mon Jan 11 2010 17:19:37 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

What does this directory structure look like exactly? How many levels?

[#] Mon Jan 11 2010 18:20:19 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Here's a script for ya.. it may not do exactly what you want, but I'm sure it could easily be changed to do exactly what you want...


#!/usr/bin/perl
use strict;

[#] Mon Jan 11 2010 18:24:35 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

oops.. well, apparently, pasting doesn't work out too well, and .ee doesn't work for me regardless of my EDITOR environment variable.

[#] Mon Jan 11 2010 18:26:41 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

#!/usr/bin/perl
use strict;

sortdir(".");
exit(0);

sub sortdir {

my($base) = @_;
my(@dirs, @files);

for(opendir(DIR, $base); $_ = readdir(DIR);) {
next if(/^\./);
if(-d) { push(@dirs, $_); } else { push(@files, $_); }
}
closedir(DIR);

foreach(sort(@files)) {
print "$base/$_\n";
}

my @sorted = sort {$b <=> $a} @dirs;
foreach(@sorted) {
sortdir("$base/$_");
}
}



[#] Mon Jan 11 2010 18:27:39 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I used webcit but it fucked up the indentation, sorry.

[#] Tue Jan 12 2010 12:03:21 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I -was- trolling you ;)

..and it worked..

I only accept trolling (and response) from people I respect, if any loser came along and tried to stick their little perl fork in me, I wouldn't have dignified them with a response.

[#] Tue Jan 12 2010 12:04:53 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

What does this directory structure look like exactly? How many levels?


It actually only goes down one level.
Root directory has 50 or so directories in it, each one a three digit number. Each directory has a pile of mp3s in it, each mp3 is prefixed with a zero padded 2 digit number.

I guess I should have said, all numbered are zero padded so they'll sort easily.

[#] Tue Jan 12 2010 12:05:42 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I used webcit but it fucked up the indentation, sorry.

Thanks, I'll take a look

Go to page: First ... 48 49 50 51 [52] 53 54 55 56 ... Last