Scanning a directory for contiguous data

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Scanning a directory for contiguous data

Post by Prospero » Tue Jun 28, 2005 1:59 am

Hi all,

This is somewhat related to my previous topic about assembling image tiles, but I think it warrants a separate thread.

My question is this:

Let's say I have a directory (such as c:\data) which is supposed to contain a whole list of files named like this (numerical order):

1.bmp
2.bmp
3.bmp
4.bmp
5.bmp
... etc etc...
Up to 500000.bmp

Now, let's suppose several of them are missing (for example, let's imagine that 543.bmp, 23726.bmp and 487421.bmp have gone AWOL). Can I make a macro to run through all the files in this directory to determine which ones are missing?

Many thanks!

Prospero
Last edited by Prospero on Tue Jun 28, 2005 3:39 am, edited 1 time in total.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jun 28, 2005 2:40 am

Here is something quick and dirty and untested......

Code: Select all

Let>Index=0
Let>UpperLimit=500000

Label>Loop
Let>Index=%Index%+1
IfFileExists>c:\data\%Index%.bmp,Found,Missing

Label>Found
//Do Stuff......Append list of files found?
If>%Index%=%UpperLimit%,End,Loop

Label>Missing
//Do Stuff......Append list of missing files?
If>%Index%=%UpperLimit%,End,Loop

Label>End
Remember to Remove Trailing Spaces if doing Cut/Paste.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Wed Jun 29, 2005 5:50 am

Bob, that works perfectly! :)

I have one last problem though, and I know it's simple... but it involves the modulus function (I read your post regarding using VB modulus btw). Problem is, I can never get my head around the modulus thing. Brain block sets in.

Anyway, at the risk of presuming to ask for even more help, here's what I need to do now:

I've managed to collect all the data I want - it's all complete and lovely. The data set goes from 1.bmp all the way up to 544968.bmp which represents an XY grid of 1044 in X and 522 in Y (i.e. a rectangle with the X:Y ratio being 2:1). Visually speaking, it is arranged like this:


... up to 544968
.............
.............................
10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 ...
9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 ...10440
8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 ...9396
7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 ...8352
6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 ...7308
5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 ...6264
4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 ...5220
3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 ...4176
2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 ...3132
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 ...2088
1 2 3 4 5 6 7 8 9 10 11 ...1044


As I think you know, this is about assembling map image data. Well, now I need to translate the file numbers back to their XY grid locations - i.e. I need to be able to specify a file number, and the macro will spit out the relevant grid XY coordinates, thusly:


1.bmp is XY 133125, 20125
2.bmp is XY 133625, 20125
3.bmp is XY 134125, 20125
4.bmp is XY 134625, 20125
5.bmp is XY 135125, 20125
...
1045.bmp is XY 133125, 20625
1046.bmp is XY 133625, 20625
1047.bmp is XY 134125, 20625
...
2089.bmp is XY 133125, 21125
2090.bmp is XY 133625, 21125
2091.bmp is XY 134125, 21125
...
etc and so on...


As you can see, the lower left XY of the grid is occupied by 1.bmp, with XY coords of 133125, 20125. The values then increment by 500 units.

I just can't figure out how to do the conversion:(

Much obliged for any help you can give me,

Prospero

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts