Rename Files with Prefix

Hope this is an easy one, I can't quite get it to work. I have 20 files with different names that I want to rename with specific prefixes.

Sample files would be something like
FileA
FileB
FileC

New names
111 FileA
222 FileB
297 FileC

Where do those numbers come from?

If you just want to paste a list of names over the existing names, there's built-in support for that. You just need to ensure that the list of new names is sorted in the same order as the old names.

If the list of new names is in a different order (e.g. because some files get lower/higher numbers relative to others that they were originally next to, and the list is sorted by the new names, not the old ones): You could still do that, but it would need a bit of script code to match up the old and new names and use the right one for each file.

More detail is needed to say which way to go.

The prefix numbers are "static". Essentially the 20 files are for a larger playlist that I have to update regularly. Once I prefix them all by hand and copy to the larger folder containing other files, when played it spaces them out the way we need.

What order are the names in the new list?

It might be easier to show us the full list of real names for the old and new files.

So with a new batch of 20 files, we rename the by hand to have the above numbers prefix them.

I'm still not sure exactly what you want to do as I can't see the full list of all the new and old names.

A list in text format is best as then we can re-create the same thing and test solutions with it.

The picture is the NEW list, the OLD list is the same files WITHOUT the 3 digit numbers.

  1. The names in the picture are truncated.

  2. A list in text format is best for us, if you want us to make a solution for you.

Please paste the full details in text format, not a cropped screenshot.

Also, do the numbers or list of files change, or are they always the same? If they are hardcoded, we can give you a simple solution that looks for name X and renames it to Y. On the other hand, If the details change, a script can be written, but we need to know how you want to feed the script the new details (e.g. via the clipboard? via a text file somewhere?)


BEFORE

AFTER

The names of the files will change often, so I'm just looking for way to prefix the 20 files with the specific numbers you see here whenever needed.

The order of the original files doesn't matter before or after the rename as long as they end up with the 3 digit prefixes. I just used the ones above for convenience.

Bump. Hope this makes sense, I seemed to have made a relatively easy one into a complicated mess in the way I described it initially. Sorry about that.

"A list in text format is best for us, if you want us to make a solution for you."

You've still only posted screenshots of the names, not text. We need text.

But I'm also still not sure where the prefixes are coming from. What are the rules for which number should go before which filename? e.g. How should the rename script (or whatever solution we end up with) know that 1x01 gets "111" but 1x02 gets "222", with 2x04 and 2x05 sandwiched in the middle? Where are those numbers coming from? Do you have them in a text file? Or are you inputting them by hand?

If they're input by hand, it's just as easy to rename the files directly. If they're coming from a list somewhere, what generates the list? Is it a text file? Can we have the text file to test the solution with?

Let's start over. I have 20 files that have different names each month that I need to rename to a set set of 3 digit numbered prefixes. The prefixes are not in any way dependent on the 20 files.

The purpose of these 20 files is that they are new content for a much bigger playlist that does respect the 3 digit numbers for their play order. The number have meaning and don't change from month to month.

We just need opus to take any 20 files I select and prefix them with a set of 20 numbers as shown.

Option Explicit

Dim fileNum
fileNum = 0

Function OnGetNewName(ByRef getNewNameData)

	Dim numPrefix
	numPrefix = Array(	111, 147, 176, 222, 297, 333, 398, 405, 444, 497, _
						503, 555, 587, 606, 666, 707, 737, 777, 888, 999 )

	If fileNum <= UBound(numPrefix) Then
		OnGetNewName = numPrefix(fileNum) & " " & getNewNameData.newname
		fileNum = fileNum + 1
	Else
		OnGetNewName = True
	End If

End Function

So you don't care which files get which numbers? Jon's script above will do that in that case.

Thank you both for your help. Sorry I didn't explain it properly to begin with. Also thank your for the screenshot, it helped me actually use it. Thanks again.