On Thu, 2004-01-15 at 23:14, mathieu perrenoud wrote:
> On Thursday 15 January 2004 23.08, Tom Wesley wrote:
> > Hi,
> >
> > After - cough - some filesystem problems (reiserfs for the curious) I'm
> > left with a lost+found directory of 9GB, about 5000 files.  Since I do
> > not have the patience of a Saint, and sadly do not employ the services
> > of a small team of highly skilled, cheap and tidy imps to do this
> > manually I am looking for somehow to script this into something more
> > manageable.
> > Does anyone have anything that will sort a large directory, preferably
> > recursively and put in into any sort of order?  Ideally I'd like to use
> > the output of "file" to move filetypes together, but can't get the
> > syntax correct...
> >
> > Any ideas, pokes, acts of random abuse welcome :-)
> 
> just a random idea.
> 
> 
> cd /away/from/lost+found
> 
> for filename in $(find /path/to/lost+found -type f); do
>   filetype=$(file"$filename"|awk -F: '{print $2}')
>   mkdir "$filetype" 2>/dev/null
>   mv "$filename" "$filetype"
>   echo "moving $filename $filetype"
> done
> 
> this should recursively move any file from lost+found to a dir whose name 
> match the file's type...
> maybe you should first try it on some test files... I'm not responsible if 
> your hdd melts down.
> 
> hth, good luck

Thanks for that, it's running and works perfectly.  Hopefully I'll be
able to sort thing a little quicker now!


-- 
Tom Wesley

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to