Dos批处理文件重命名
我有一组这样命名的文件(单词可以是任何单词或数字):
Word word-word word word Floor B2342 Word Word-word.pdf
Word word-word word Floor: B-2342 Word Word-word.pdf
Word word- Floor C43 Word Word.pdf
Word word word- Floor- E2AD342 Word Word.pdf
我想重命名文件夹中的所有内容,只包含 Floor 后面的组...您可以指望 Floor 始终位于文件中名称以及我想保留的内容如下楼层。
B2342.pdf
B-2342.pdf
C43.pdf
E2AD342.pdf
一个衬垫会很好,但也可以更多,因为它将位于 .bat 文件中。主要关注的是稳健性。
I have a group of files that are named as such (word can be any word or numbers):
Word word-word word word Floor B2342 Word Word-word.pdf
Word word-word word Floor: B-2342 Word Word-word.pdf
Word word- Floor C43 Word Word.pdf
Word word word- Floor- E2AD342 Word Word.pdf
I want to rename everything in the folder to only have the group that follows Floor... You can count on Floor always being in the file name and what I want to keep following floor.
B2342.pdf
B-2342.pdf
C43.pdf
E2AD342.pdf
A one liner would be nice but it can be more since it will be in a .bat file. The main concern is being robust.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果还不算太晚的话,你能尝试一下我的这个小批处理脚本吗?它处理当前目录中的所有 .pdf 文件。如果名称没有“Floor”部分,脚本将跳过该文件。
您可能已经注意到令人惊讶的
COPY
命令而不是RENAME
。它是按设计而存在的。我只是想让你先确定一切是否顺利。不过我已经测试过了,这个脚本似乎没有任何问题。只有一件事。您的示例名称之一包含冒号字符,这在文件名中是非法的。我在测试期间已将其替换为“#”。
If it isn't too late, will you try this out little batch script of mine? It processes all .pdf files in the current directory. If a name has no 'Floor' part, the script just skips the file.
You may have noticed the surprising
COPY
command instead ofRENAME
. It is there by design. I would just like you to make sure first if everything's going to be smooth. I've tested it, though, and there doesn't seem to be anything wrong with this script.Only one thing. One of your sample names contains the colon character, which is illegal in file names. I've replaced it with '#' during my tests.