通过更改一个文件的部分名称来重新命名一组模板文件的批处理代码(要复制的所有文件更改为相同的文本)

发布于 2024-07-29 02:54:38 字数 998 浏览 4 评论 0原文

我创建了一个包含文件夹作为模板的文件系统,用于重新创建一组信息,以便在我们接受预订并需要批处理命令以非常具体的方式重命名目录中的所有文件时使用。 更准确地说,该目录包含: 一个文件是发票模板(PDF 格式) 另一个是职位描述模板(MSWord) 还有一个是用于特殊目的的附加模板(也称为 MSword)。
还有更多文件,但我想我不需要全部命名。

每次处理预订时,我所做的就是复制模板目录(包含所有这些文件模板),然后根据工作编号重新命名。 然后,我将其重新定位到“预订”目录下,并将其放入代表预订该工作的年份月份的文件夹中。

在第一步中,我怎样才能让目录中的所有文件自动重命名以适应。 目录中的每个文件的命名都不同,但是当我手动重命名每个文件后,它们都共享一个共同因素,即作业编号。 所以我需要的只是将每个文件名的一部分更改为该预订的作业编号,其余文件名保持原样。 我认为这将节省我处理的预订数量的大量时间。 (CRM 软件即将出现,但现阶段还有些遥远)。

例如,如果我更改模板目录 从名称“template”到“CFI-00123 (1P2H)”,然后在目录中名为“invoice# 000.pdf”的文件应变为“invoice# CFI-00123.pdf”和另一个文件 名为“job# 000.docx”应该变成“job# CFI-00123.docx”

什么使事情变得复杂: 工作编号如下所示:CFI-00123 (2PBR)。 所以该目录将被准确命名。 然而,我想要在其中的文件中复制的部分只是“CFI-000123”,而不是括号中的部分(2PBR)。 这只是附加信息,可帮助我一目了然地确定工作的要求是什么,我不需要其中的每个文件来反映这一点。

我从来没有写过批处理代码,而且我对使用 html 的理解很模糊,所以我需要有人准确地告诉我该做什么、该写什么。

感谢您提前抽出时间,如果您有任何问题,我会尽力尽可能清楚地说明。 希望这不是太难理解。

干杯, 丹尼.

I have created a filing system containing folders as templates for re-creating a set of information to be used when we accept bookings and need a batch command to rename all files within a directory but in a very specific way. So to be more precise the directory contains:
one file is an invoice template (PDF form)
and another is a job description template (MSWord)
and yet another is an additional template for special purpose (Also MSword).
There are a few more files also but i guess i don't need to name them all.

What i do each time i process a booking, is to copy the template directory (containing all these file templates) and then re-name it according to job number. I then re-locate it under a "bookings" directory and drop it into the folder representing the month of the year the job is booked for.

In the very first step, how could i get all the files within the directory to rename automatically to suit. Each file in th edirectory is named differently but when i am finished renaming each file manually they all share the one common factor which is the job number. So what i need is just for part of each of the file names to change to the job number for that booking, leaving the rest of the file name as it was. i figure this will save alot of time with the number of bookings i process. (CRM software is on the horizon but still a little too far away at this stage).

For example if i change the template directory
from the name "template" to "CFI-00123 (1P2H)" then within the directory a file named "invoice# 000.pdf" should become "invoice# CFI-00123.pdf" and another file
named "job# 000.docx" should become "job# CFI-00123.docx"

What complicates things:
a job number looks something like this: CFI-00123 (2PBR). So the directory will be named as that exactly. However the part that i want to be replicated in the files within, is the "CFI-000123" only and not the part in bracketts (2PBR). This is just additional inforamtion that helps me identify at a glance what the requirement of the job is and i don't need each of the files within to reflect this.

I have never written batch code and i have a vague understanding when using html so i need someone to tell me exactly what to do and what to write.

thank you for your time in advance and if you have any questions i'll try to be as clear as possible. Hope this is not too difficult to understand.

Cheers,
Danny.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒中人 2024-08-05 02:54:38

首先,这个布局看起来还可以吗?

  _Software
      |_Booking
          |_Template
          |_...
          |_CFI-00120 (1P2H)
          |_CFI-00121 (1P2H)
          |_CFI-00122 (1P2H)
          |_CFI-00123 (1P2H)

-其次,是的,所有需要重命名的文件都需要在 OP 中列出,因此请编辑您的帖子,然后添加到列表中以便于阅读。

评论这篇文章,以便我再次阅读。

To start with, does this layout seems ok?

  _Software
      |_Booking
          |_Template
          |_...
          |_CFI-00120 (1P2H)
          |_CFI-00121 (1P2H)
          |_CFI-00122 (1P2H)
          |_CFI-00123 (1P2H)

-Second, yes all files needing to be renamed need be listed in OP, so edit your post and add then, in a list for ease of reading.

Comment this post so I read again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文