merge - 按名称从文件列表中获取最新文件并将其与 Windows 批处理文件中的另一个文件合并?

标签 merge batch-file windows-console

我有一个文件夹中的文件列表。它们的命名如下:2011-04-14_00-00-24

示例列表:

2011-04-14_00-00-24
2011-04-13_00-01-12
2011-07-08_00-00-28
2010-03-12_00-00-45
...

现在我想根据该列表中的文件名获取最新文件,在本例中为 2011-04-14_00-00-24。我得到的文件应该与另一个文件合并。我如何获取最新文件并合并这两个文件?

谢谢:-)

最佳答案

您可以通过以下方式获取最新文件:

for /f "delims=" %%x in ('dir /o-n /b') do (set "Latest=%%x" & goto le)
:le

我不太清楚你所说的合并是什么意思;如果这是连接两个文件:

copy somefile+"%Latest%" newfile

关于merge - 按名称从文件列表中获取最新文件并将其与 Windows 批处理文件中的另一个文件合并?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5660304/

相关文章:

mercurial - Mercurial —通过放弃一个变更集 “merge”

git - git merge --no-ff 和 git merge --squash 有什么区别

python - 如何在 Windows 10 控制台中使用对 ANSI 转义序列的新支持?

c++ - 在 Windows 控制台应用程序中输出 unicode 字符串

c++ - 如何在不影响 Windows 操作系统上的 C++ 中的文本颜色的情况下更改整个控制台的背景颜色

mysql - 合并 MySQL 中的 2 个表并自动填充缺失的列

r - 将 purrr reduce 列命名更改为数字?

java ProcessBuilder 不起作用

bash - 如何从 git bash 使用命令行 Visual Studio 编译器?

linux - 如何将 Linux shell 脚本转换为 Windows 批处理文件?