Calling all scripting experts.... HELP!!!!!

Caporegime
Joined
28 Feb 2004
Posts
74,822
Hi all,
I have a little challenge for you all that should be pretty easy to sort out if you have even a modicum of scripting knowledge, which sadly I do not, I really must get round to learning someday.

I have a whole bunch of files, approx 2500 so far, but increasing daily, that are all of the format

B1000.hdr, B1000.log, B1000.plg, B1000.alg, B1000.slg, B1000.hlg, B1000.clg, B1000.eot, B1000.fin.

then the next bunch are named B1001...., then B1002....., etc, etc, you get the picture I hope.

These files need moving from one folder, where they are all jumbled up together, in to another set of folders that are more organised.

The new folders are in a set of directories named as
B1000 - B1999
B2000 - B2999
etc etc

In each directory I need the folders named
B1000
B1001
B1002
etc etc

Then the files with extension names .log, .plg, .alg, .slg, .hdr, need copying into their appropriate folder. The other files can be left in the original folder.

Up to now I have been creating new folders manually and copying and pasting the necessary files, as you can imagine, this is somewhat tedious and mind numbingly boring.
I am sure a little script or batch file could make the job so much easier and faster, but I do not have a clue wher to start, so I am calling on the vast knowledge and expertise of OCUK to help stop my fingers wearing away to nothing.
Obviously if there is any more info needed just ask.
Thank you, and sorry for the length of the post.
 
Is this on Windows or something UNIX(like) that has a sensible scripting language?

First comment would be to change the names of the first level of paths from "B1000-B1999" to simply "B1000" or the like, that way you can generate the target path name as a simple substring with a fixed string appended to it rather than having to calculate the part after the dash.


It is in windows XP, I'm afraid, just be gratefull as we only changed from Windows 2000 in june, and the machine that the files originally come from is still running NT4, but we copy them to CD and transfer them to the main system for backup which is where this organising comes in.

I do not have control over the way the level of paths have been set up,
I have only recently taken over this particular task here at work, and it is a case of "this is the way we do it, we have always done it this way, just get on with it".

I'm afraid it is a very dinosaur type of company, they do not like change in any way, and that makes it very hard to do anything economically.


Edit:


I'm beginning to get the feeling this may not be as easy as I thought, sorry :o
 
Last edited:
It's not too bad, I'll have a look into knocking something up for you when I get a spare 5 minutes at work, unless anyone else wants to jump in first of course.

Bear in mind though, doing this in windows means you'll have to use the FileSystemObject which working on 22,500 files, and 2,503 folders will take some time to process when you run it :)


Cheers, that would be great.
I get used to things taking time to process, imagine sitting waiting for a high speed movie file averaging 2.5-4 gig in size, getting converted into an AVI, it can take anything up to a couple of hours on our best machine, a dual core with two gig of ram, most machines are P4's with 512Mb maybe 1gig of ram.
 
Cheers Spunkey, no real rush if you can do something it would be great. :)

I have tried a very rough, nasty, ugly, batch file along the lines of what rpstewart was talking about, it kind of does the job, but it needs a fair bit of tidying up afterwards, and obviously a lot of re-writing for the next batch of files etc.
 
Back
Top Bottom