简体   繁体   中英

sejda-console.bat passing parameters with spaces

I am using sejda-console.bat and I am running into difficulties with parameters when there is a space involved.

I am trying to use the simplesplit feature and I am calling the console as follows:

call sejda-console.bat simplesplit -f %1 -o %~dp1 -s all

If the path to my file is:

Z:\Test\test.pdf

The script works perfectly. However if the path to my file is:

Z:\Test Folder\test.pdf

It fails with the following error:

call sejda-console.bat simplesplit -f "Z:\Test Folder\test.pdf" -o Z:\Test Folder\ -s all
18:16:29.746 Configuring Sejda 1.0.0.M2
18:16:29.777 Loading Sejda configuration form default sejda.xml
18:16:30.027 Starting execution with arguments: 'simplesplit -f Z:\Test Folder\test.pdf -o Z:\Test Folder\ -s all'
18:16:30.027 Java version: '1.7.0_25'
18:16:30.199 Option only takes one value: --output -o value : output directory (required)

I wonder is there anyone who is familiar with the sejda-console or just passing parameters with spaces that could point me in the right direction. I have searched widely and tried all possible combinations of parameters etc.

Thanks

我认为您也应该对-o选项使用引号:

call sejda-console.bat simplesplit -f "Z:\Test Folder\test.pdf" -o "Z:\Test Folder\" -s all

I'd suggest to convert the long directory path names to short path names For example: use C:\\TESTFO~1\\ as opposed to C:\\test folder with spaces

This seems to solve the issue,

Below a working example calling the sejda-console from an AutoIt script

#include <Constants.au3>

Local $iPID, $sOutput = ""

$sFilePath = "C:\test folder with spaces\"
$sFileShort= FileGetShortName($sFilePath)
$iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" merge -l " & $sFileShort & "files.csv -o " & $sFileShort & "output.pdf --overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

ProcessWaitClose($iPID)
$sOutput = StdoutRead($iPID)
ConsoleWrite($sOutput)

Having just hit and solved this exact problem, this is a sample of what I am passing to sedja.

simplesplit -j overwrite -s all -f "C:/Users/user/Desktop/PDF_splitting/pages.pdf" -o "C:/Users/user/Desktop/PDF_splitting/spaced path/" -p [BASENAME]_[CURRENTPAGE]

So, even though my system is Windows 10 I can use forward slash "/" as a path separator. Wrap the whole path in double quotes and it works.

I think the reason a 'normal' path string doesn't work is that the backslash "\\" is an escape character in Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM