批处理文件重命名“This.is.a.FIlename.mp3”到“tiaf.mp3”
好的,我有一个包含一些文件的目录。我想做一个特定的文件重命名脚本 我坚持这部分,只取文件名每个部分的第一个字母:
如果文件名是,
This.is.a.FIle.mp3
我想重命名它以
tiaf.mp3
注意到我希望它全部为小写。
字长是可变的,所以我不能将其作为局部变量进行引用!变量:~0,2!
有人可以帮忙吗? 谢谢!
编辑:我忘了问。如果您有想法进行测试,文件名是否符合我提到的格式。因为如果调用该文件。 'file.mp3' 那么我不希望它被重命名为 'f.mp3'
okay so I have a dir with some files. I want to do a specific file-renamingscript
i'm stuck with this part, taking only the first letter of each part of the filename:
if the filename would be
This.is.a.FIle.mp3
I would like to rename it to
tiaf.mp3
notice i want it to be all in lowercase.
The word length is variable so i cant take reference from it as a local variable !variable:~0,2!
anyone could help?
thanx!
edit: i forggot to ask. If you have an idea to make a test if the filename is of the format i mentioned. Because if the file is called. 'file.mp3' then i wouldn't want it to be renamed to 'f.mp3'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可行,但如果您也想允许“!”文件名中带有感叹号,则必须稍微扩展一下。
This should work, but if you want to allow also "!" exclamation marks in your filenames, it have to be a little bit extended.
这种逻辑对您有用吗:
您可以更改 echo %a%、echo %b% 等来设置并从中获取子字符串。这也只获得前 4 个分割,如果需要,您可以添加更多分割。还将 C:\temp 更改为适当的目录。
Would this kind of logic work for you:
You can change the echo %a%, echo %b%, etc. to sets and get the substring from these. This also only gets the first 4 splits, you can add more if you need. Also change C:\temp to the appropriate directory.