cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Member
New Member

Setting PDF metadata with filename - find and replace?

Jump to solution

Is it possible to perform find/replace when setting metadata with the filename?

Eg:

Filename: "First_second_&_third".pdf

Required metadata: "First second and third"

0 Kudos
6 Replies
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Setting PDF metadata with filename - find and replace?

Jump to solution

One option is to use the Optimize node. For the Keywords entry use $FFwfJob.jobName$. This will put the filename into the PDF metadata field for Keywords. Optimize.png

 

0 Kudos
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Setting PDF metadata with filename - find and replace?

Jump to solution

You may be looking for the Process Variable Operations.  Look in the FreeFlow Core Help for the details:

Process Variable Operations.png

Highlighted
Frequent Member
Frequent Member

Re: Setting PDF metadata with filename - find and replace?

Jump to solution

In Core 5.4.5 there is no ltrim and rtrim in help at Process Variable Operations. Did something changed?

I want to extract from filename 2 or 3 digits before "x" and before "mm", and then process as a variable. Is it posible?

0 Kudos
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Setting PDF metadata with filename - find and replace?

Jump to solution

The ltrim and rtrim capabilities are still present in FFCore. Unfortunately there was a problem when Help was updated. Help has been fixed for FFCore 6.0.0.

0 Kudos
Highlighted
Frequent Member
Frequent Member

Re: Setting PDF metadata with filename - find and replace?

Jump to solution

I want to extract from filename 2 or 3 digits before "x" and before "mm", and then process as a variable. Is it posible?

0 Kudos
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Setting PDF metadata with filename - find and replace?

Jump to solution

To get information from a file name you can create a manifest on the fly. Here is an example for a similar request. A customer would like to extract ABC and 32ex as variables from a pdf with this name:

FO146390_ABC_49180_5214_32ex_SRA3_Komplett.pdf

This PowerShell script that you need to run on a hotfolder with parameters $FFin$ and $FFout$ will create a manifest extracting the required information from the file name using two regular expressions ($regex1 and $regex2) and write those into columns in the manifest. The variables can then be used as for instance in a Watermark.

$filepath = Get-Item $args[0]
$filename = $filepath.Name
$maxfile = "C:\Temp\$filename.txt"
$regex1 = '^.*?_(.*?)_.*?_.*$'
$regex2 = '^.*?_.*?_.*?_.*?_(.*?\d*).*$'
$preset = ($filename -split $regex1)[1]
$copies = ($filename -split $regex2)[1]
Copy-Item $filepath -Destination "C:\Temp\"
Set-Content -Path $maxfile -value "C:\Temp\$filename;$preset;$copies" -NoNewLine
$outpath= $args[1].Substring(0,$args[1].Length-1)
Copy-Item -Path $maxfile -Destination $outpath

You would need to find the correct regular expression for the information you would like to extract from the file name. Here is one https://regex101.com/ or google regex tester.

For something like:

123xsomefilename210mm.pdf

\d+(?=x) would give 123 and x*(\d+)(?=mm) would give 210

/Stefan

0 Kudos