I have a NAS appliance that crashed last weekend. The IT guys apparently / maybe didn't recover it in the right way? There's about 50,000 directories in a "lost+found" directory each with a numeric name like "#4289756". It looks as if all the missing files are within these directories, each with the original date and owner information (Linux). I need to organize them so they are findable to the staff.
My goal is to copy / move these files into a structure so that each employee has their own folder with their own files, and each folder is further divided by month.
The appliance itself is running a Busybox, a stripped down Linux version that only supports a subset of the typical Bash commands. I thought I could use a script with the "find" command to sort them by owner and date and then pipe that to "-exec cp" to the appropriate place, but it looks like Busybox doesn't have that ability.
Here's a suggestion someone had, but it assumes the original directories have the correct UIDs, which is not the case.
cd /lost+found ; for i in *; do USER=`ls -l $i | awk '{print $3}'`; mkdir -p /home/$USER/recovered ; cp -a $i /home/$USER/recovered/$i ; done