NConvert Can't Create File

NConvert Can't Create File

So i am receiving the following error in Powershell

.\nconvert.exe :   Error: Can't create file (\\vm912test\c$\JCL Testing\Converted Output\2013\06\MMM7777.pdf)
At M:\Powershell\test4.ps1:61 char:8
+        .\nconvert.exe -quiet -out pdf -c 3 -multi -n 1 $PageCount 1 -o "$OutputL ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (  Error: Can't ...06\MMM7777.pdf):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

If anyone has any experience working with nConvert that could help that would be great.
The line of code that i am using is:

.\nconvert.exe -quiet -out pdf -c 3 -multi -n 1 $PageCount 1 -o "$OutputLocation\$Year\$Month\$BusinessUnit$CheckNumber.pdf" "$TIFPath\$pattern####.tif"
2

1 Answer

You need to add quotation marks to the output filename, because it countains spaces. I usually do this to force an external command to be formated exactly as I want it to be:

$myCommand = "nconvert -q 100 -out tif -overwrite -o " + ('"' + $OutputFilePath + '"') + " " + ('"' + $InputFilePath + '"')

write-host $myCommand

invoke-expression $myCommand

Use write-host to check the formating and run the command verbatim using invoke-expression.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.