Okay a bit of a hard one to explain but there is a bug in a program we use that can't be fixed for reasons that are too long and boring to go into so I'm trying to come up with a workaround.
The problem is that if you previously joined files together in a particular program, very occasionally when you next come to join different files together it selects the new files and the old files together.
All of the files I DO want to join together are in a folder the path to which I've previously captured as variable AF1
There is also a window in this particular program we are using that effectively shows all the files that are open. This will show the ones I do want to join and the ones that shouldn't actually be there.
What I was thinking of doing was to go down this list of files, capture each file name, compare it against the list of files in AF1 and then have it delete any files that are not in AF1.
What I can't work out though is how can I capture all the names of the files open in this window when I've no idea how many files it will be showing. For example I might have chosen to join 8 files together but that window could show 9,11,20 files.
The window looks like this
In order to capture the file name you have to tab label field once you've selected a file and then copy it. How would it know it's come to the bottom of the list?
Read File Names In Window, compare and delete
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Read File Names In Window, compare and delete
If you have a loop which tabs through each file in the list, capturing the filename as it goes, compare the filename just captured to the previously captured filename. If equal you must be at the end, so break out of the loop.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Read File Names In Window, compare and delete
Cheers Marcus, but that's the problem. Lets say I have 9 files in my folder but for some reason when I open them up, this program lists 15 files as being open. If I set the loop to equal the file count (9) it won't check 6 of the files listed in this program. I will have no way of knowing what files this program thinks it's opened before they are opened and the only place the files are listed are in this window.
I could tab through the list of files in this window and visually I'll know when I've got to the bottom of the list but I don't know how to tell the macro where the end of the list is and to stop there.
I could tab through the list of files in this window and visually I'll know when I've got to the bottom of the list but I don't know how to tell the macro where the end of the list is and to stop there.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Read File Names In Window, compare and delete
You must misunderstand me. I said nothing about file count. You don't know the file count. Have an *INFINITE* loop which moves from one line to the next. (Not sure how you do that - press the down key I guess). Compare filename to last filename. If equal, break out of the loop. Just use a Label/Goto. Without checking the filename it will try and go forever. But each time you extract the filename you compare to the last extracted filename. If they are the same you must be stuck at the last line. I'm assuming that if you try and go down to the next line while on the last line, nothing will happen. You'll be stuck at the last line and therefore the captured filename won't change and therefore you're on the last line, so jump out. Maybe instead it moves to the first line. In which case store the first captured filename and then if your captured filename = first captured filename, you're at the end. Point is you look at what happens when you try and move past the last line and use what happens to your advantage.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Read File Names In Window, compare and delete
Ahh yes <Sound of penny dropping>
That makes sense and a much more elegant way of doing it compared to the convoluted code I was trying to write.
Cheers Marcus.

That makes sense and a much more elegant way of doing it compared to the convoluted code I was trying to write.
Cheers Marcus.