How to add the date in rename script?

Idea is to select 10 files, prefix with numbers with the script below
but need to ADD the current date to the end of the file name.

myfilename.mp4 becomes 111 myfilename.mp4 CURRENT SCRIPT
myfilename.mp4 becomes 111 myfilename 2019-04-14 DESIRED NAMING SCRIPT

Option Explicit

Dim fileNum
fileNum = 0

Function OnGetNewName(ByRef getNewNameData)

	Dim numPrefix
	numPrefix = Array(	111, 147, 176, 222, 251, 297, 333, 355, 398, 405 )

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

End Function

Replace getNewNameData.newname with

getNewNameData.newname_stem & " " & DOpus.Create.Date().Format("D#yyyy-MM-dd") & getNewNameData.newname_ext

(assuming you want to keep the extension).

Thank you, that works perfectly. I've been trying to make the date + 10 days from now and can't quite get it. I can change them manually, but I'm unclear on how to format +10, should be easy.

new name date would be 2019-04-24

Yes, no big deal. Getting the vbscript right was the hardest part :smiley:

Option Explicit

Dim fileNum
fileNum = 0

Dim numPrefix
numPrefix = Array(	111, 147, 176, 222, 251, 297, 333, 355, 398, 405 )

Dim newDate
Set newDate = DOpus.Create.Date()
newDate.Add 10, "d"

Function OnGetNewName(ByRef getNewNameData)
	If fileNum <= UBound(numPrefix) Then
		OnGetNewName = numPrefix(fileNum) & " " & getNewNameData.newname_stem & " " & newDate.Format("D#yyyy-MM-dd") & getNewNameData.newname_ext
		fileNum = fileNum + 1
	Else
		OnGetNewName = True
	End If
End Function
1 Like

Perfect again. Thanks, you have no idea how much time this saves us. Thanks!