批处理文件来检测文件名的一部分 [英] Batch file to detect only part of a filename

查看:140
本文介绍了批处理文件来检测文件名的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个可以检测到文件名的一部分批处理文件的一个片段,然后将其重命名。
注意,该文件名后的数字随机变化,而是文件是始终不变的。

I need a snippet of a batch file that can detect part of a filename, then rename it. Note that the numbers after the filename change randomly but "file" is always the same.

例如:

文件名:file143424

filename: file143424

有将永远是唯一一个需要的文件夹中要重命名的文件。该脚本将删除旧版本的文件。比如,我把文件夹内的第一个文件,并在那里过的脚本。我然后运行脚本,它重命名它只是文件中。然后,如果我把一个新的文件,脚本,再次运行时,会从文件preFIX识别它,并重新命名它删除旧后到文件。

There will always be only one file that needs to be renamed in the folder. The script will delete older versions of the file. For instance, I put a first file inside the folder and the script in there too. I then run the script, which renames it to just file. Then if I put a new file in, the script, when run again, will recognize it from the "file" prefix and rename it to file after deleting the old one.

推荐答案

对不起。你的问题是不完整的,我想。要重命名file134342到什么?

Excuse me. Your question is incomplete, I think. You want to rename "file134342" to what?

在你的评论说:重命名为只是文件,但是这只有当有刚的有一个的文件,使用该名称。总之,这里是:

In your comment you said: rename it to just "file", but this works only if there is just one file with that name. Anyway, here it is:

for %%f in (file*) do ren %%f file

如果这不是你想要什么,然后给我们更多的细节(您showld总是给从一开始就全部细节)。

If this is not what you want, then give us more details (you showld always give full details from the very beginning).

这篇关于批处理文件来检测文件名的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆