Author Topic: bulk: rename files with folder name  (Read 3994 times)

0 Members and 1 Guest are viewing this topic.

Nick Riviera

  • Newbie
  • *
  • Posts: 22
bulk: rename files with folder name
« on: November 13, 2020, 02:52:37 PM »
Hi,

Does PDF-ShellTools  have capability to rename files with folder name..?

ex:

folder name:
"November2020"

files that are in this folder:
"November2020_01.pdf"
"November2020_02.pdf"
"November2020_03.pdf"
...

Thank you very much.

RTT

  • Administrator
  • *****
  • Posts: 918
Re: bulk: rename files with folder name
« Reply #1 on: November 14, 2020, 01:48:01 AM »
You can do it with the renamer tool.
You need to add a script function that will be used to get the folder name. To do that, open the scripts editor, functions menu Scripts>Manage scripts, and create a new script called FolderName with this code in it:
Code: [Select]
function FolderName() {
    var parts = BatchFile.Filename.split('\\');   
    return parts[parts.length - 2]
}
Or, from the script editor main menu, import the attached FolderName.myscript file.
Close the script editor, saving the changes.

You can now set a rename formula like this:

[FolderName]_[Counter:1|1|2|A]

To get file names as in your example.

Nick Riviera

  • Newbie
  • *
  • Posts: 22
Re: bulk: rename files with folder name
« Reply #2 on: March 02, 2021, 03:43:50 PM »
Thank you!!!