Macro to name files.

superfb

Active Member
Joined
Oct 5, 2011
Messages
255
Office Version
  1. 2007
Platform
  1. Windows
Hi guys,

I have a list of file names listed from 1-15 for examples.

I also have documents scanned in to a folder.

The first scanned item (determined by the time it was scanned compare to others) is generally the 1st file name.

The second scanned item will be done few mins after the first one and that will be the second name on the list.

Instead of renaming these files one by one can a macro help? Predetermined by the timings of the scan documents. .....
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi
- need a bit more info from you, thanks

1. Are Docs ALWAYS in the same Docs folder?

2. Are Scans ALWAYS in the same Scans folder?

3. Do the folders ALWAYS contain the EXACT same number of documents when you run the macro?

4. Exactly what is a typical file name?- what is the whole name including extension?
- are the first few characters of the name ALWAYS identical and followed by a number
- are numbers of equal length or not
File names are treated as text. You want to match the 10th created image (based on time -which is straightforward) to the Document with filename ending in 10
As is obvious from below we need to be careful in telling VBA which is the 10th document!

Files named f1 to f102 sorted

f1 , f10 , f100 , f101 , f102 , f11 , f12 , f13 , f14 , f15 , f16 , f17 , f18 , f19 , f2 , f20 , f21 , f22 , f23 , f24 , f25 , f26 , f27 , f28 , f29 , f3 , f30 , f31 , f32 , f33 , f34 , f35 , f36 , f37 , f38 , f39 , f4 , f40 , f41 , f42 , f43 , f44 , f45 , f46 , f47 , f48 , f49 , f5 , f50 , f51 , f52 , f53 , f54 , f55 , f56 , f57 , f58 , f59 , f6 , f60 , f61 , f62 , f63 , f64 , f65 , f66 , f67 , f68 , f69 , f7 , f70 , f71 , f72 , f73 , f74 , f75 , f76 , f77 , f78 , f79 , f8 , f80 , f81 , f82 , f83 , f84 , f85 , f86 , f87 , f88 , f89 , f9 , f90 , f91 , f92 , f93 , f94 , f95 , f96 , f97 , f98 , f99

Files named f001 to f102 sorted
f001 , f002 , f003 , f004 , f005 , f006 , f007 , f008 , f009 , f010 , f011 , f012 , f013 , f014 , f015 , f016 , f017 , f018 , f019 , f020 , f021 , f022 , f023 , f024 , f025 , f026 , f027 , f028 , f029 , f030 , f031 , f032 , f033 , f034 , f035 , f036 , f037 , f038 , f039 , f040 , f041 , f042 , f043 , f044 , f045 , f046 , f047 , f048 , f049 , f050 , f051 , f052 , f053 , f054 , f055 , f056 , f057 , f058 , f059 , f060 , f061 , f062 , f063 , f064 , f065 , f066 , f067 , f068 , f069 , f070 , f071 , f072 , f073 , f074 , f075 , f076 , f077 , f078 , f079 , f080 , f081 , f082 , f083 , f084 , f085 , f086 , f087 , f088 , f089 , f090 , f091 , f092 , f093 , f094 , f095 , f096 , f097 , f098 , f099 , f100 , f101 , f102

5. Does the 10th document name in the folder ALWAYS end in 10
- would only be the case if the first document ALWAYS ends in 1
- in other words are we asking VBA to start at 1 every time?

6. Would you be able to adopt a different document naming pattern when originally created or are the names determined by another process?
 
Upvote 0
Hi
- need a bit more info from you, thanks

1. Are Docs ALWAYS in the same Docs folder?

No the folder is always different..i guess I could always put the file location in a cell and a macro could pick it up.

2. Are Scans ALWAYS in the same Scans folder?

Again the scanned documents are always in a different folder.

3. Do the folders ALWAYS contain the EXACT same number of documents when you run the macro?

The number of documents can vary from 1-50 potentially

E.g. 1 file may have 6
2nd file may have 15

4. Exactly what is a typical file name?- what is the whole name including extension?
- are the first few characters of the name ALWAYS identical and followed by a number
- are numbers of equal length or not
File names are treated as text. You want to match the 10th created image (based on time -which is straightforward) to the Document with filename ending in 10
As is obvious from below we need to be careful in telling VBA which is the 10th document!

The file name to be copied over - the names tend to vary so it's hard to have a consistent file name

Files named f1 to f102 sorted

f1 , f10 , f100 , f101 , f102 , f11 , f12 , f13 , f14 , f15 , f16 , f17 , f18 , f19 , f2 , f20 , f21 , f22 , f23 , f24 , f25 , f26 , f27 , f28 , f29 , f3 , f30 , f31 , f32 , f33 , f34 , f35 , f36 , f37 , f38 , f39 , f4 , f40 , f41 , f42 , f43 , f44 , f45 , f46 , f47 , f48 , f49 , f5 , f50 , f51 , f52 , f53 , f54 , f55 , f56 , f57 , f58 , f59 , f6 , f60 , f61 , f62 , f63 , f64 , f65 , f66 , f67 , f68 , f69 , f7 , f70 , f71 , f72 , f73 , f74 , f75 , f76 , f77 , f78 , f79 , f8 , f80 , f81 , f82 , f83 , f84 , f85 , f86 , f87 , f88 , f89 , f9 , f90 , f91 , f92 , f93 , f94 , f95 , f96 , f97 , f98 , f99

Files named f001 to f102 sorted
f001 , f002 , f003 , f004 , f005 , f006 , f007 , f008 , f009 , f010 , f011 , f012 , f013 , f014 , f015 , f016 , f017 , f018 , f019 , f020 , f021 , f022 , f023 , f024 , f025 , f026 , f027 , f028 , f029 , f030 , f031 , f032 , f033 , f034 , f035 , f036 , f037 , f038 , f039 , f040 , f041 , f042 , f043 , f044 , f045 , f046 , f047 , f048 , f049 , f050 , f051 , f052 , f053 , f054 , f055 , f056 , f057 , f058 , f059 , f060 , f061 , f062 , f063 , f064 , f065 , f066 , f067 , f068 , f069 , f070 , f071 , f072 , f073 , f074 , f075 , f076 , f077 , f078 , f079 , f080 , f081 , f082 , f083 , f084 , f085 , f086 , f087 , f088 , f089 , f090 , f091 , f092 , f093 , f094 , f095 , f096 , f097 , f098 , f099 , f100 , f101 , f102

5. Does the 10th document name in the folder ALWAYS end in 10
- would only be the case if the first document ALWAYS ends in 1
- in other words are we asking VBA to start at 1 every time?

We would be asking the macro to look at the scanned folder, see which one is scanned first by looking at the time. And then copy file number 1.

This should work as long as the scanned documents are scanned in order of file no 1, file no2


6. Would you be able to adopt a different document naming pattern when originally created or are the names determined by another process?
The names are predetermined by the scanning in the printer when you email yourself the copy.

I hope this helps and thank you for taking the time out to reply.

Please see answers above. Thank you
 
Upvote 0
Can you provide one example scenario
- names of all files in the documents folder
- names of all files in the scanned folder
- names of files in documents folder after renaming

Would you prefer to browse for the 2 folders?
 
Upvote 0
Hi

Apologies the names of the document will be from an excel spreadsheet.

I don't have access to the data until Monday.

If I could have a macro button that allows me to insert the file location of the scanned docks would be awesome
 
Upvote 0
No problem
To prevent heading down the wrong track, I would rather use a complete "real" example - should get us closer to what you want first time
What I need to understand is the "pattern" from which to create a rule for VBA to apply generally
 
Upvote 0
Hi,

So I think it would be good if one macro gathers the name from a file specified by me (the file location put into a cell preferablly)

Then I enter the name in a second column and press a second macro button to name the files.

When I save the files, i try and save them as 1,2,3,4,5,6,7,8 if the scanner allows me to predetermin the names.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top