No idea who originally wrote this, I know I didn't. Credit to whoever did.
Create a button that runs a "Standard Function (Opus or External)" with this code:
[code]Rename FILEINFO FROM="." TO="{DlgStringS|Folder name and number range to create:|Folder Name,1,20}"
@script vbscript
Option Explicit
' Number of digits to pad the number to. For example, if PadTo
' is 3 then the script will generate 001, 002, 003, 004, etc..
Dim intPadTo
intPadTo = 3
' For information on the technique used in this button see:
' "Abusing" Rename Scripts to do other things with file info
' [OBSOLETE] "Abusing" Rename Scripts to do other things with file info
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
Dim strTemp
Dim strFolderName
Dim intLast
Dim intCurrent
Dim strCurrent
Dim strCreatePath
Dim intComPos
if intPadTo < 1 then
intPadTo = 1
end if
strFolderName = ""
intCurrent = 0
intLast = 0
intComPos = InStrRev(strNewName,",")
if intComPos > 0 then
strTemp = Trim(Right(strNewName,Len(strNewName)-intComPos))
if IsNumeric(strTemp) then
intLast = CInt(strTemp)
strTemp = Trim(Left(strNewName, intComPos-1))
intComPos = InStrRev(strTemp,",")
if intComPos > 0 then
strFolderName = Trim(Left(strTemp, intComPos-1))
strTemp = Trim(Right(strTemp,Len(strTemp)-intComPos))
if IsNumeric(strTemp) then
intCurrent = CInt(strTemp)
else
strFolderName = "" ' Prevent anything from happening
end if
end if
end if
end if
' Set strNewName to an empty string so that Opus does not rename the file.
strNewName = ""
if strFolderName <> "" then
while intCurrent <= intLast
strCurrent = CStr(intCurrent)
If Len(strCurrent) < intPadTo Then
strCurrent = String(intPadTo - Len(strCurrent), "0") & strCurrent
End If
strCreatePath = strFilePath & "\" & strFileName & "\" & strFolderName & " " & strCurrent
if fs.FolderExists(strCreatePath) or fs.FileExists(strCreatePath) then
DOpus.OutputString "Skipping " & strCreatePath
else
DOpus.OutputString "Creating " & strCreatePath
fs.CreateFolder(strCreatePath)
end if
intCurrent = intCurrent + 1
wend
end if
End Function[/code]
The default settings in the above code will create:
Folder Name 001
Folder Name 002
.
.
.
Folder Name 019
Folder Name 020
When clicked, the script will ask you what the folder name and range is to be. Entered in as so:
Folder Name,Starting Number,Ending Number
The code above is set to use 3 digits for the numbering, but you can change that by adjusting this line:
intPadTo = 3