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

时间:2021-03-19 16:24:59

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.

我创建了一个包含文件夹作为模板的文件系统,用于重新创建在我们接受预订时使用的一组信息,并且需要批处理命令来重命名目录中的所有文件,但是以非常具体的方式。因此,为了更精确,目录包含:一个文件是发票模板(PDF表单),另一个是作业描述模板(MSWord),另一个是特殊用途的附加模板(也是MSword)。还有一些文件,但我想我不需要将它们全部命名。

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).

在第一步中,如何让目录中的所有文件自动重命名以适应。该目录中的每个文件的命名都不同,但是当我手动重命名每个文件时,它们都共享一个公共因子,即作业号。所以我需要的只是将每个文件名的一部分更改为该预订的作业号,保留文件名的其余部分。我认为这将节省我处理的预订数量的大量时间。 (CRM软件即将推出,但在此阶段仍然有点太远)。

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"

例如,如果我将模板目录从名称“模板”更改为“CFI-00123(1P2H)”,则在目录中名为“invoice#000.pdf”的文件应变为“invoice#CFI-00123.pdf”而另一个名为“job#000.docx”的文件应该成为“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.

使事情复杂化的是:工作号码看起来像这样:CFI-00123(2PBR)。所以该目录将被精确命名。但是,我希望在其中的文件中复制的部分仅是“CFI-000123”而不是括号中的部分(2PBR)。这只是一个额外的信息,可以帮助我一目了然地确定作业的要求是什么,我不需要其中的每个文件来反映这一点。

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.

我从来没有编写批处理代码,而且在使用html时我有一个模糊的理解,所以我需要有人告诉我到底要做什么和写什么。

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.

1 个解决方案

#1


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.

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

Comment this post so I read again.

评论这篇文章,我再读一遍。

#1


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.

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

Comment this post so I read again.

评论这篇文章,我再读一遍。