#1 : 27/11-24 13:14 Fabrice BARBOT
Posts: 1
|
Hello,
To archive files, they must be renamed, it works very well with this software. But I have to limit the number of characters in the file name to 31 including the file extension. I would like this software to tell me the number of characters when it is renamed. Do you have a script to do this? Or even to prohibit renaming if it has more than 31 characters? For information I asked an AI, but the script he gave me does not work and does not display anything, I do not know why. (I am not a programmer and my knowledge is limited. Thanks |
#2 : 28/11-24 03:49 Delta Foxtrot
Posts: 364
|
Reply to #1:
Reply to #1: Hi Fabrice, welcome, There are several things that might work for you, see what you think: 1. You use whatever batch you now use to rename the files,, then add a method that cuts the any names longer than you want down to your 31 characters. A replace method with: Replace: <Name> With: <substr:1:28> with Apply to: set to Name and assuming a 3-character extension. -OR- Replace <Name> With: <substr:1:15>~<rsubstr:1:15> with Apply to: set to "Name and extension" if your extensions vary. That would insert a tilde (or whatever) where the files were split, possibly making the name more legible. (?) 2. You could use a method that reverts to the old filename if the new filename is too long. As the last method: Replace: ^.{29}.*\.(.*) With: <Name> with Regular Expressions checked to revert back to the old name if the filename body is more than 28 characters long. Again, probably not ideal. 3. Here's a script that, if the full name is more than 31 characters it reverts to the original name and adds "====" to the start of the filename: //--------------- fileLength alert fileLen = ( item.newBasename.length + item.ext.length ) ; if ( fileLen > 31 ) { newName = "===="+item.name ; return newName ; } //----------------- -OR- the following just reverts to the original filename (before any changes in the method list) if the name is too long, so the "New Filename" entry is greyed out and nothing would change on that file. //----------------- fileLen = ( item.newBasename.length + item.ext.length ) ; if ( fileLen > 31 ) { return item.name; } //----------------- That's all I've got off-hand... maybe somebody else will have more (better) ideas. :) Also it's hard to make specific suggestions without actually seeing filename representative examples. Best, DF |
#3 : 28/11-24 09:28 Delta Foxtrot
Posts: 364
|
Reply to #2:
Fabrice, You could also use a script like this: //----------------- fileLen = ( item.newBasename.length + item.ext.length ) ; if ( fileLen > 31 ) { newFilename = item.newBasename.substr( 0, ( 31 - item.ext.length ) ) + item.ext ; } return newFilename ; //----------------- But again, that just chops out whatever is over the limit from the filename, so I don't know if that's better in any way. Just giving you options. Oh, you'd need to set the "Apply to:" field to "Name and extension". Best, DF |