I have about 1,000 word documents downloaded from a customer's document software. The file names are some sort of numerical sequence number. I need to have the "real" document name which is located in the title value field in the document properties per the screen shot below.
All of these Word documents are on a flash drive with the assigned drive letter of "F" in a folder named "marketing". I know nothing about VBA, etc. but wondered if there is a way to access the "title" value field in the document properties and use this value to replace the numerical file name.
For the document identified in the screen shot below, it is named 00058578.DOC and I need to rename it to SOS Letter for.DOC. This will be extremely time consuming to do manually.
All suggestions are welcome.
JimC
[img]c:eileens.jpg[/img]
Rename 1,000 Word Doc Files using Title Value in Properties
-
- 3StarLounger
- Posts: 386
- Joined: 08 Feb 2010, 16:08
Rename 1,000 Word Doc Files using Title Value in Properties
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rename 1,000 Word Doc Files using Title Value in Properties
See if this works. It is a VBA macro that can be run from Word or Excel or PowerPoint, whichever you prefer.
Code: Select all
Sub RenameFiles()
Dim objShell As Object
Dim objFolder As Object
Dim objFile As Object
Dim p As Long
Dim sExtension As String
Dim sNewName As String
Set objShell = CreateObject(Class:="Shell.Application")
Set objFolder = objShell.NameSpace("F:\marketing")
On Error Resume Next
For Each objFile In objFolder.Items
p = InStrRev(objFile, ".")
sExtension = Mid(objFile, p)
sNewName = objFolder.GetDetailsOf(objFile, 21) & sExtension
objFile.Name = sNewName
Next objFile
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 386
- Joined: 08 Feb 2010, 16:08
Re: Rename 1,000 Word Doc Files using Title Value in Properties
Hans, as always your willingness to share your knowledge is greatly APPRECIATED. I won't be able to try this code until Friday afternoon as I will be away from my computer until then. I will report back once I can run it. Again, thank you. JimC
-
- PlutoniumLounger
- Posts: 16070
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Rename 1,000 Word Doc Files using Title Value in Properties
Hello Jim. I have absolute confidence in Hans's VBA method, but in case you are not comfortable with VBA for a job at short notice you may find VoidTools's "Everything" useful. In the Result List you can add a gazillion different columns. In the screen shot above I have added "Title" and "Word Count" as just two of the many document properties available to you.
There is still some work - installing Everything, working out which Document attributes you need to develop a unique name (if your client has cloned documents you may find that several documents bear the Title of the original document).
I can help you with Everything.
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
The most expensive thing a man can own is ignorance.
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rename 1,000 Word Doc Files using Title Value in Properties
Can one use Everything to rename files?
Best wishes,
Hans
Hans
-
- PlutoniumLounger
- Posts: 16070
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Rename 1,000 Word Doc Files using Title Value in Properties
In a word, yes.
My response was based on a few thoughts:
(1) JimC had written "All suggestions are welcome." which made me look for non-VBA solutions since JimC had mentioned that he knew nothing about VBA.
(2) Some installations will prohibit VBA solutions on principle, remembering the viruses of Normal.dot a quarter century ago
(3) Especially for a more general solution, Everything has superior search mechanics. That is, as a front-end it is empowered to build a comma-delimited file list; with such a file list one can easily build a batch file using a simple Excel spreadsheet to get the renaming job done.
(4) Everything supports RegEx operations and RegEx support exists both Here and There,
That said, my preference would be for a VBA solution (although more low-level than yours) because my programming background asserts itself to say "Oh! Write a program".
I have not used Rename in Everything, although a quick Advanced Search suggests a fertile ground.
On top of that the VoidTools forums are probably the second-friendliest forums in The Known Universe, so help is at hand there, too
Cheers, Chris
The most expensive thing a man can own is ignorance.
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rename 1,000 Word Doc Files using Title Value in Properties
I see that you can use basic file properties in Everything Advanced Renamer. If Title is among those, it would indeed be an easy way to accomplish the task.
Best wishes,
Hans
Hans
-
- PlutoniumLounger
- Posts: 16070
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Rename 1,000 Word Doc Files using Title Value in Properties
I agree. And remember the Rename would take effect on the Result List, and that Result List can be formed in more ways and under more conditions than we can imagine!
FWIW I have attached a screenshot of the Attributes currently supported (Right hand pane) under Documents (Left pane)
Now, which of us is going to set up a Trial System?
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
The most expensive thing a man can own is ignorance.
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rename 1,000 Word Doc Files using Title Value in Properties
I have no experience with Everything Advanced Renamer, but my guess would be that it would be faster than VBA once you have set it up correctly.
Best wishes,
Hans
Hans
-
- PlutoniumLounger
- Posts: 16070
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Rename 1,000 Word Doc Files using Title Value in Properties
Here is a real-life example that surprised me:- Everything has searched for, and presented me with a Result List, of 14 files which I want to Rename. In particular I want to strip that "Diary_" prefrix from all fourteen file names.
In the image I have circled the Everything's analysis of my filenames. Note that Everything has allocated two variables - %1 and %2 - to the pattern of the strings that make up the filenames. In this sub-image we see that Everything has recognized that the datestamp portion of the filenames is a consistent pattern of characters, while the timestamp portion is a different pattern.
This I know: were I to write a solution in VBA I would be programming my way around this, at the very least with the benefit of "Left()", "Right()" and "Mid()" equivalents. And then I would be writing slightly different VBA for the next set of files tomorrow.
Everything has the string analysis embedded within the application.
I daresay it isn't perfect, but it relieves some of the repetitive re-coding for a new set of files that appears tomorrow.
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
The most expensive thing a man can own is ignorance.
-
- 3StarLounger
- Posts: 386
- Joined: 08 Feb 2010, 16:08
Re: Rename 1,000 Word Doc Files using Title Value in Properties
Hans, Chris,
Thank you. I will try this out later this week. My wife has COVID and priorities have been re-arranged while she is sick. I will report back, but it may be a week or so delay. JimC
Thank you. I will try this out later this week. My wife has COVID and priorities have been re-arranged while she is sick. I will report back, but it may be a week or so delay. JimC
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rename 1,000 Word Doc Files using Title Value in Properties
I hope your wife recovers soon!
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 386
- Joined: 08 Feb 2010, 16:08
Re: Rename 1,000 Word Doc Files using Title Value in Properties
Hans---Thank you for the well wishes. This is her 5th time with COVID, and so far, no hospital stay like the last 3 infections. One day at a time. Take care, JimC