批量重命名文件 - 追加第 1 行和第 2 行3
我使用的是 Windows 7。我有一堆文本文件,每个文件都包含一封电子邮件。每个都是这样开始的:
FROM:Person 致:另一个人 日期:2011 年 1 月 1 日 18:12:00 主题: 不管怎样
我想重命名这些文件,使它们的名称如下所示:
2011-01-01 18.12 Email from Person to Another Person reWhatever.txt
批处理编程是我所知道的,但我不太了解。为了将其限制在我可以快速理解的项目中,我认为最好的解决方案是将基本数据提取到一个文本文件中,然后我可以将其合并到批量重命名文件中。
在这种情况下,我正在寻找一个批处理文件,它将数据提取到文本文件中的单行中,然后我可以通过全局编辑将其调整为形状。换句话说,我想我正在寻找这种格式的文本行:
[当前文件名] [提取的日期和时间字符串] [来自] [到] [主题]
示例:
file01.txt 01-Jan-11 at 18: 12:00 从一个人到另一个人无论什么
如果我有这样的行,我可以在 Excel 中很快地将它们解析为重命名命令。
谢谢!
I'm using Windows 7. I have a bunch of text files, each containing one email message. Each starts this way:
FROM: Person
TO: Another Person
DATE: 01-Jan-11 at 18:12:00
SUBJECT: Whatever
I want to rename these files so that their names look like this:
2011-01-01 18.12 Email from Person to Another Person re Whatever.txt
Batch programming is all I know, and I don't know it very well. For purposes of restraining this to a project that I can understand quickly, I think my best solution will be to extract the essential data into a text file that I can then massage into a batch renaming file.
In that case, what I'm looking for is a batch file that will extract the data into single lines in a text file that I can then massage into shape with global edits. In other words, I think I'm looking for text lines in this format:
[current filename] [extracted date and time string] [from] [to] [subject]
Example:
file01.txt 01-Jan-11 at 18:12:00 from Person to Another Person re Whatever
If I've got lines like that, I can parse them into renaming commands pretty quickly in Excel.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
鉴于您使用的是 Windows 7,我想我会建议一个替代方案。 Windows Powershell 是一个非常有用的命令工具,可用于做很多事情。我想我解决了你的完整问题:
它做了一些假设(就像总会找到匹配项)。您可以轻松调整命名格式和其他内容。将此代码保存为脚本 (.ps1) 并在 Powershell 提示符 (powershell.exe) 中运行它
Given that your using Windows 7, I thought I'd suggest an alternative. Windows Powershell is a a very useful command tool that can be used for a ton of stuff. I think I solved your complete problem:
It makes a few assumptions (like a match will always be found). You can easily adjust naming format and other things. Save this code as a script (.ps1) and run it in the Powershell prompt (powershell.exe)