Jump to content
Macro Express Forums

set variable from filename, but which file?


Recommended Posts



I regularly receive a CD with a large number of files which must be reorganized into our system. I've been using Macro Express with great success for this, but there is one step which I'd like to automate. The folder structure of the CD is D:\123456 and in that folder there are two files, R54wX.doc and R54qw.xls. There are several hundred folders, and in each, there are these two filenames (though the files themselves have different contents). Each CD provides new random filenames, and I cannot see the reason behind the names. I would like to set a variable by the filename of the .doc file, but how can I get Macro Express to know which file I want?


Thank you.

Link to comment
Share on other sites

A good start would be to tell us how you decide which file you want. Describe in detail the processes you use to determine your target file.

Is it only 1 file you use from the entire CD, or what?


The way I determine my target files are by the extension. In my example, my macro uses an excel spreadsheet to change the file from D:\123456\R54wX.doc to C:\files from CD\123456_John Smith.doc


The folder numbers (i.e. 123456) and client name are part of my spreadsheet, so the macro knows which folder is associated with which client. It then looks at the next line in the spreadsheet, gets the new number and name as variables, and uses the new number in the path to find the file. The difficulty I'm having is that each of the 200+ folders have 2 files in them, one .doc, and one .xls. In each folder, the files have the same name, but I don't know what that name will be, only the extensions. So to run this process, I currently have to browse the CD for the filename, then edit my macro to correct the filename for this CD.


I hope that is more clear, and to specifically answer your question, I use 1 file out of each of the 200+ folders, and I know which file I want by the extension.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...