Sign in to follow this  
Followers 0
makeinstall

Reading files in folders to copy

4 posts in this topic

I'm trying to get my head around the best way to solve this problem but I'm still a n00b with programming in general so I'm not coming up with viable, elegant solutions.

The problem is thusly:

I am writing a script to copy specific users files to a network location but there may be more than one of a particular file type. How do I find out how many there are and copy those up to my preselected network location? More specifically, its copying users email ID files but there is no uniformity to them because of a few reasons.

1. Some users have legacy ID's from a big changeover a couple of years ago whereas users employed less than 3 years ago have the new format. [old format is GBxxxxxx.id and the new is GBxxxx.id]

2. A few people have 2 or sometimes 3 of these ID files in their data folder so to only copy the first one found would be fatal to the process.

I though that a good way would be to cycle through FileFindFirstFile & FileFindNextFile, add the results to an array and then later cycle through the array copying those files but my mind tends to go with the most elaborate [and therefore easily breakable] solution before looking for the simplest.

Can anybody offer a good engineering solution or prod me in a new direction to think about the problem and eventual solution?

Thanks in advance!

./chris

Share this post


Link to post
Share on other sites



No need for a complicated regular expression if you are only looking for files of the format GBxxxxxx.id and GBxxxx.id. You can just use a wildcard for your FileFindFirstFile filter (i.e. FileFindFirstFile("GB*.id"))

Share this post


Link to post
Share on other sites

Thanks zorphnog.

I did poop myself a little when I started to look at those RegExp scripts after the sensation of something passing over my head had passed ;-) . But how will your suggestion find ALL of the file types in the folder?

I think I'm asking the wrong question there. Whats the best way to store the results? Would it be to create a counter within FileFindNextFile loop and then assign the result to the value of $Array[counter]?

Thanks for all the help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0