Rename PATTERN "*" TO "* {filecount}" FILEINFO TYPE=dirs
Should work, but does not work.
Maybe Leo could answer why {filecount} could be selected as fileinfo field in rename but would not bring the input.
Possible a bug.
I think you would have to use a button script or rename script to do this. The rename command won't count files in sub-folders by itself, but if it runs a script the script can do so pretty easily.
This only counts files directly below each folder. (Change ReadDir(GetNewNameData.item, False) from to use True at the end instead if you want it to be recursive.)
It counts all files, but if you want it to only count files with specific extensions that's easy enough to add.
If the folder name already has a count, it will be removed and replaced by the new count.
[code]@script vbscript
Option Explicit
Dim re
Set re = New RegExp
re.Pattern = "^(.*)( (\d))$"
Function OnGetNewName ( ByRef GetNewNameData )
Dim folderEnum, folderItem, fileCount, matches
If (GetNewNameData.item.is_dir) Then
' Count files in folder.
fileCount = 0
Set folderEnum = DOpus.FSUtil.ReadDir(GetNewNameData.item, False)
Do While (Not folderEnum.complete)
Set folderItem = folderEnum.Next
If (Not folderItem.is_dir) Then
fileCount = fileCount + 1
End If
Loop
' Return new name.
' If the name already has a count at the end, remove it first.
Set matches = re.Execute(GetNewNameData.newname)
If (matches.Count > 0) Then
OnGetNewName = matches(0).Submatches(0) & " (" & fileCount & ")"
Else
OnGetNewName = GetNewNameData.newname & " (" & fileCount & ")"
End If
End If
End Function[/code]
Whoo! Leo you helped out here, while I was busy putting some pieces together. So Leonard you have 2 "starting points" then. o)
You might try the command I created especially for this purpose, I didn't think of a rename script somehow, but a command should do equally well.
The only thing it does not (yet?), compared to Leos solution, is removing an already existing number from the foldername.