寻找一个简单的批处理脚本来修改文件名
我的文件夹中有一个以 .swf
结尾的文件列表。
我想将所有这些文件从 X.swf
更改为 X
。
我怎样才能做到这一点?
I have a list of files in a folder that end with .swf
.
I want to change all those files from X.swf
to X<some number>.swf
.
How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个小脚本会将所有
*.swf
文件更改为等效的*_42.swf
文件。实际上,就目前而言,它只会回显它想要执行的命令。一旦您确信它们是正确的,您只需从上面的重命名行中删除
echo
即可。它的工作原理是使用
for /f
获取所有 SWF 文件的列表,然后使用字符串操作来:.swf
扩展名);然后_42.swf
扩展名。并且,请确保先备份它们:-)
This little script will change all
*.swf
files into the equivalent*_42.swf
files.Actually, as it stands now, it will just echo the commands that it wants to execute. Once you're happy they're correct, you can just remove the
echo
from that renaming line above.It works by using
for /f
to get a list of all SWF files and then using string manipulation to:.swf
extension); then_42.swf
extension onto the end.And, please, make sure you back them up first :-)
您可以直接在命令提示符下使用以下一行:
其中
123
代表您选择的数字。或者,您可以创建一个批处理文件并利用其接受参数的能力。使用以下脚本:
现在,如果批处理的名称是
renamer.bat
,您可以像这样调用它:它会将
2011
添加到每个的名称中。当前目录中的 .swf
文件。You could use the following one-liner directly from the command prompt:
where
123
stands for your number of choice.Alternatively you could create a batch file and take advantage of its ability to accept parameters. Use the following script:
Now if the batch's name is
renamer.bat
, you can invoke it like this:and it will add
2011
to the name of every.swf
file in the current directory.假设您的描述中的
应该是不变的,并且您没有明确需要批处理脚本来解决您的问题,您可以使用 Windows 资源管理器,如 Microsoft 标题为“< a href="http://windows.microsoft.com/en-US/windows7/Rename-a-file" rel="nofollow">重命名文件"。以下是上述文章的摘录:
“您还可以一次重命名多个文件,这对于对相关项目进行分组非常有用。为此,请选择文件[然后按 F2]。键入一个名称,然后键入每个文件将以新名称和末尾的不同序列号保存(例如,重命名文件 (2)、重命名文件 (3) 等)。”
Assuming
<X>
in your description is supposed to be constant and you don't explicitly require a batch script to solve your problem, you can use Windows Explorer as mentioned in an article by Microsoft titled "Rename a file".Here's a an extract from said article:
"You can also rename several files at one time, which is useful for grouping related items. To do this, select the files [then press F2]. Type one name, and then each of the files will be saved with the new name and a different sequential number at the end (for example, Renamed File (2), Renamed File (3), and so on)."