用于提取文件名的一部分并相应地重命名的批处理文件 [英] Batch file for extracting part of a file name and renaming it accordingly

查看:129
本文介绍了用于提取文件名的一部分并相应地重命名的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用原始文件名的一部分重命名大量文件。我想创建一个批处理文件来提取此信息并重命名文件。 



示例:


原件:


ag_record_74_136_17604878902_2728622.wav


ag_record_76_136_12527728500_2730331.wav


ag_record_76_136_12522233874_2863170.wav



我希望它们分别出现(分别)


7604878902.wav


2527728500.wav


2522233874.wav



有人可以帮助吗有了这个。提前谢谢。

解决方案

要求有人为您编写脚本不是本论坛的目的。


开始学习PowerShell并使用PowerShell完成。它比在批处理文件中进行笨拙的文本解析容易得多。


从学习Get-ChildItem开始,它返回文件对象。


然后,您可以获取每个文件对象的Name属性,并使用Substring方法或正则表达式获取所需的新名称,然后使用Rename-Item重命名文件。


这是对PowerShell的首次介绍,以及它如何真正为您节省大量工作。


或者,寻找一个可以帮助您进行大规模重命名的程序。


I have a large number of files that I need to rename using part of the original file name. I would like to create a batch file to extract this information and rename the files. 

Examples:

Originals:

ag_record_74_136_17604878902_2728622.wav

ag_record_76_136_12527728500_2730331.wav

ag_record_76_136_12522233874_2863170.wav

What I would like them to come out as (respectively)

7604878902.wav

2527728500.wav

2522233874.wav

Could someone please help with this. Thank you in advance.

解决方案

Asking for someone to write a script for you is not the purpose of this forum.

Start learning PowerShell and do it using PowerShell. It will be far easier than trying to do clumsy text parsing in a batch file.

Start with learning Get-ChildItem, which returns file objects.

Then you can get the Name property of each file object, and use the Substring method or a regular expression to get the new name you want, then use Rename-Item to rename the files.

This is a great first introduction to PowerShell and how it can really save you a lot of work.

Alternatively, look for a program that helps you do mass renames.


这篇关于用于提取文件名的一部分并相应地重命名的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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