Automated export using Powershell

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
User avatar
David_KM
Posts: 4
Joined: Thu Aug 01, 2019 9:37 am

Automated export using Powershell

Unread post by David_KM »

Hi guys,

maybe this Powershell script will be helpful, it saves me a lot of time. I personally use it for automated export of multiple projects included in specific directory into one specific output format.

PS

Code: Select all

$helpman = 'enter path to Help+Manual .exe file' 
$runPath = 'enter complete path for directory where all respective files are stored'
$template = "enter path for template file"

$filthmxz = Get-ChildItem -Path $runPath -Include *.hmxz -Recurse -Force | Where-Object {$_.Directory.Name -ne 'enter the name of directory not included in search, e.g. if there is some folder with previous versions' }

$filthmxz | %{

$originfile = "$($_.FullName)"
$outputfile = "$($_.Directory.FullName)\$($_.Name)"
$log = "$($_.Directory.FullName)\$($_.BaseName).txt"

$arg = @("`"$($originfile)`"" #cmd switches listed in H+M helper, written in form understandable for PS 
"/PDF=`"$($outputfile)`"" #select output format
'/I=PDF' #select publishing settings
"/Template=`"$($template)`""
"/L=`"$($log)`"" #optional, creates .txt file in same folder as .hmxz file with basic console output only
'/debug' #optional, if used, manual confirmation for each file is necessary
)

Write-Host "Starting helpman for: $($_.FullName)" #optional
Write-Host $arg #optional

Start-Process $helpman -ArgumentList $arg -PassThru -NoNewWindow

}

#create list of exported items with export date

$index = "enter path to index file"

$filtpdf = Get-ChildItem -Path $runPath -Include *.pdf -Recurse -Force | Where-Object {$_.Directory.Name -ne 'enter the name of directory not included in search, e.g. if there is some folder with previous versions' }

Add-Content $index -Value (Get-Date) -PassThru

$filtpdf | Select-Object -Property BaseName, LastWriteTime | Sort-Object -Property BaseName, LastWriteTime | Out-String -Width 8 | Out-File $index -Append
#hope this helps :)
David Zaremba
KM Technology
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Automated export using Powershell

Unread post by Tim Green »

Hi David,

Thanks for posting this. Are you aware of the Publishing Task Manager with which you can set up jobs like this from within Help+Manual?

https://helpandmanual.com/help/hm_worki ... tasks.html
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
David_KM
Posts: 4
Joined: Thu Aug 01, 2019 9:37 am

Re: Automated export using Powershell

Unread post by David_KM »

Hi Tim,

yes, I am quite familiar with it, PS is just my personal preference.

This script solves compatibility problem occured during processing CMD switches in PS (unavailability to read variables after making PS dumber with --% ) at first.

Maybe somebody will find this useful.
David Zaremba
KM Technology
Post Reply