I have a school fileserver with each student having their own account in /home as shown here...

/home/judy
/home/larry
/home/greg
/home/karen
(etc)

Students are in three class group (junior, middle and senior known as $GROUP1 $GROUP2 and $GROUP3) although I don't really want to add that complication to my script right now except to say that the wanted scripts COULD be formed along the lines of...

for STUDENT in $GROUP3 do { ..... }

...ignore that if you want (it could just do all students in /home dir), as it's a side issue. Just something you can use if you like. Here's the real question:

Students in the SENIOR group (for example) have made a lot of pov ray modeler files (which end in the *.kpm prefix). I want to make a colection.sh script which will go through the senior /home dirs and copy all files in those directories into a new one at /home/collection, RENAMING each file as tom1.kpm tom2.kpm tom3.kpm tom4.kpm and so forth, depending on their username. What this means is that I will have a "collected works" (/home/collection) directory where I can quickly sort through student files to look at the items of the file type I am wanting.

The script must not of course also reproduce stuff from the /home/collection directory itself
The script should be recursive just in case students decided to organise their work into subdirs

Preferably, the script would be executed along the lines of

./colection.sh GROUP3 *.kpm

...to collect all the student files in the list $GROUP3 which end in .kpm

It's the sort of thing I love to nut out myself (for my own learning) although I'm kind of pressured for time at the moment, so your help is appreciated.

Actually, the reason I didn't get back yet was because the perl solution somewhat confused me, as I do not know perl (It does not look harder than other languages, but the /\/\/\/\/\ syntax throws me a bit, which is why I specified BASH). I thereby was in no position to modify the perl script for a few other things I wanted to do, but did not want critique a solution which, if I only right now had the time to study perl, was in all likelyhood a perfectly viable solution (hence lack of a reply). Instead used the following script to get the job done...

...where $DIRNAME was given the name of the target "collection" directory for the wanted file type and the $FILELIST were results of a manual [/b]find[/b] for the file type I was wanting to collect in the /home/dirs.

Not an ideal solution, as I had to manually edit my code each run for every file type based on my manual find query. Also, the inability of my own code to handle file names with spaces meant I had to manually read through screeds of "file not found" errors each run and manually mget the misnamed files via ftp from the file server, one by one.

A damned lengthy process which took hours. I still haven't managed to mark the work I collected. Fortunately, the classes were cancelled due to outside courses etc or I would have certainly missed the deadlines altogether.

The backslashes "" are escape characters in regular expressions. They mean "use the ASCII character that follows". The special characters "/" (forward slashes) and "." (periods) are used to separate or group strings of characters but they also signify the directory structure "/home/username/filename.ext" or special matching characters like \w ("a-zA-Z0-9_" = alphanumeric characters & _) and \n (newline).

There are a number of online resources to help with Perl (when you get time ) like Learn Perl and The CGI Site. I know LXF is doing some shell scripting but Perl is also very powerful and can also interact with Web Servers very well.