Using Win2PDF & Microsoft’s Power Automate Desktop to Rename PDFs

Our last post — Get Into Your PDF Flow using Microsoft’s Power Automate Desktop Software — gave an overview of the Power Automate Desktop software and how it can be used to automate repetitive tasks with PDF files.

Over the next series of posts we’ll show some examples of how this can be done in a real-world context using Win2PDF.

First, let’s start off by using an example where we want to automatically rename a bunch of PDF invoices that are stored in a folder. And then suppose we not only want to rename the PDF files, but we want the new file names to be based on some content within the original files, such as the number following the word “INVOICE”.

In the following example (see Microsoft Power Automate for Desktop flow for renaming PDF based on File Contents for details), we’ll search through each PDF in the folder and rename the file based on an invoice number that follows the word “INVOICE”. Here’s what the desktop flow looks like:

Notice how the Win2PDF command line getcontentsearch feature is used. It allows us to search for the word “INVOICE” in the PDF file, and then return the following content (in this case, the INVOICE number) to the standard output. After trimming any extraneous spaces from this invoice number, the PDF file is renamed to be that invoice number.

You can use the graphical user interface to make your own flow, or you can copy the following into a new Power Automate Desktop flow if you want to use this as a starting point for your project:

# This flow searches the contents of PDF files in the selected folder for SearchText, and renames the PDF files based on the text immediately following SearchText.  Change the SearchText variable to the desired search field.  Note : the SearchText field is case sensitive.
SET SearchText TO $'''INVOICE :'''
Display.SelectFolder Description: $'''Select Folder to Rename''' IsTopMost: False SelectedFolder=> SelectedFolder ButtonPressed=> ButtonPressed3
Folder.GetFiles Folder: SelectedFolder FileFilter: $'''*.pdf''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
LOOP FOREACH CurrentItem IN Files
    # Search for %SearchText% field and return following text in CommandOutput using the following Win2PDF command line:
    # C:\Windows\System32\spool\drivers\x64\3\win2pdfd.exe getcontentsearch "%CurrentItem%" "" "%SearchText%"
    System.RunDOSCommand DOSCommandOrApplication: $'''C:\\Windows\\System32\\spool\\drivers\\x64\\3\\win2pdfd.exe getcontentsearch \"%CurrentItem%\" \"\" \"%SearchText%\"''' StandardOutput=> CommandOutput StandardError=> CommandErrorOutput ExitCode=> CommandExitCode
    IF CommandExitCode = 0 THEN
        Text.Trim Text: CommandOutput TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
        File.Rename Files: CurrentItem NewName: $'''%SelectedFolder%\\%TrimmedText%''' KeepExtension: True IfFileExists: File.IfExists.Overwrite RenamedFiles=> RenamedFiles
    ELSE
        Display.ShowMessageWithTimeout Title: $'''Win2PDF Renamer''' Message: $'''Could not find \"INVOICE :\" field for file %CurrentItem%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False Timeout: 10 ButtonPressed=> ButtonPressed4
    END
END

This example shows one way to use Win2PDF’s automation features to create a solution unique to your workflow. It also uses features that were added in the latest Win2PDF 10.0.100 update, so make sure you are using the latest Win2PDF 10 Update when trying any of the Power Automate Desktop features.

Can you think of any similar cases that you might use? If so, drop us a line. We’ll have more examples coming soon.

Get Into Your PDF Flow using Microsoft’s Power Automate Desktop Software

Soooo many requests:

“I wish there was an easy way to convert all of these text files to PDF automatically.”

“Why can’t I just save an entire series of web pages as searchable PDF files?”

“How can I consolidate weekly reports from different applications and formats to a single PDF file without spending my whole afternoon doing so?”

These and other questions arrive in our email inbox daily. It seems everybody has some level of repetitive PDF processing that they do and are looking for an easier way to get it done. And since many of these issues are specific to a particular application or to your own business process, it’s not easy to find a one-size-fits-all solution that gives you the type of “push button” solution you really want.

That’s one reason why we’ve been so focused on creating tools like Win2PDF Auto-name, Win2PDF command-line processing, Win2PDF Plug-ins, and Win2PDF mail integrations. All of these features give powerful automation control to the user to eliminate repetitive steps and reduce processing errors.

Now, there’s something that combines all of these Win2PDF “tools” into a single problem-solving toolkit that works with all of your files and other applications. And best yet, it won’t cost you a penny!

Microsoft’s new Power Automate Desktop software is a free download for Windows 10 users that allows you to easily automate any repetitive tasks from your desktop, including the creation or manipulation of PDF files using Win2PDF. Once installed, you just need to create a desktop flow (the series of steps that automate a specific action or task). And no, you don’t need to be a coder to use it. Microsoft has a simple interface that most anyone can use.

It’s quite easy to build your first desktop flow using either pre-built drag-and-drop actions or by recording your own desktop flows to run later. For this latter method, it works similar to macros in Microsoft Office, by recording repetitive actions from your desktop across multiple applications—like your web browser, Microsoft Excel, Microsoft Outlook, Win2PDF, etc.—and then lets you replay the automation whenever needed.

For example, a quick desktop flow to convert all TXT files in a folder to PDF using Win2PDF (using the Win2PDF Auto-name feature) might look something like this:

A very simple recipe like this could save you a lot of time if you are currently working with PDF files regularly and in the same manner.

We’ll be diving into this topic in a bit more detail in future posts, including some more detailed examples where this might be useful. In the meantime, get into the flow and download the Power Automate Desktop software today and look at the Win2PDF Power Automate documentation to see what it can do for you.