Can I get a button that would auto move the sets to their own folders, named after the file name up to the separator (the separator can be "_" or "-")? Example:
I'm trying to do the same as above but this time by grabbing X amount of characters from the beginning and making that the folder. Example, this works for grabbing the first 4 characters:
Rename REGEXP PATTERN "(.{4})(.+)" TO "\1/\1\2"
Instead of making buttons for "3", "4", "5" etc characters, I'm trying to set the character count value to a variable:
@set count={dlgstring|Enter the number of characters to use}
Rename REGEXP PATTERN "(.{{$count}})(.+)" TO "\1/\1\2"
But it just doesn't seem to work. It moves only 1 file (with the wrong name), then pops-up the rename dialog box to rename the others (since the same name already exists). Plus it moves it to a weird named folder that's up one root level. Any help would be appreciated!
While I'm asking (I'd rather have this button instead). Is it at all possible to first ask which character spot to start from? Then ask how many characters to grab? That why, I can start grabbing from character 5 and go 3 characters. Example:
tripday01_001.jpg
tripday01_002.jpg
Would move the above files into a "day" folder.
If there is a ton of coding that needs to be done, then never mind. I'll just make separate buttons then
It seems the {{$count}} requires escaping the first { and last }, but I don't know what the escape character is for this. I've searched the docs, but can't find it, nor how to concatenate strings into a single string.
Rename TO "{dlgstring|Enter the number of characters to use}"
@script vbscript
option explicit
Function Rename_GetNewName ( strFileName, strFullPath, fIsFolder, strOldName, ByRef strNewName )
Dim intChars
intChars = CInt(strNewName)
if (intChars < 1) then
strNewName = strFileName ' Do nothing
else
strNewName = Left(strFileName,intChars) & "\" & strFileName
end if
End Function
Or this one, which also makes sure it doesn't take characters out of the file extension, if the number you give is greater than or equal to the length of the main part of the filename:
Rename TO "{dlgstring|Enter the number of characters to use}"
@script vbscript
option explicit
Function Rename_GetNewName ( strFileName, strFullPath, fIsFolder, strOldName, ByRef strNewName )
Dim intChars
Dim intExtensionPos
intChars = CInt(strNewName)
intExtensionPos = InStr(strFileName, ".")
if fIsFolder or 0 = InStr(strFileName,".") then
intExtensionPos = Len(strFileName) + 1
end if
if (intChars < 1 OR intChars >= intExtensionPos) then
strNewName = strFileName ' Do nothing
else
strNewName = Left(strFileName,intChars) & "\" & strFileName
end if
End Function
Thank you for your time and expertise Leo! And again to MrC, for my other buttons. I now have a nice little collection to handle just about any scenario that I might have (at least what I've seen so far). These buttons are saving me a ton of clicks and hours of time. Thank you!
Leo - is it correct that it is not possible to embed a {$xyz} control code inside curly braces (i.e. no escape char within a string)? I can see this would have some utility.