私は比較的簡単になるように夢中になっています... File/folder chooser dialog from a Windows batch scriptのコードを使用してファイルダイアログを開いて、複数のファイルを選択させます。 次に、選択した結果を1つの文字列に連結して、別のアプリケーションにパラメータとして渡す必要があります。1文字列のファイルダイアログの出力を連結する
<# : chooser.bat
:: launches a File... Open sort of file chooser and outputs choice(s) to the console
:: https://stackoverflow.com/a/15885133/1683264
@echo off
setlocal
set slctn=
for /f "delims=" %%I in ('powershell -noprofile "iex (${%~f0} | out-string)"') do (
echo You chose %%~I
set slctn=!slctn!|%%~I
)
REM here use %slctn% in another command
echo %slctn%
goto :EOF
: end Batch portion/begin PowerShell hybrid chimera #>
Add-Type -AssemblyName System.Windows.Forms
$f = new-object Windows.Forms.OpenFileDialog
$f.InitialDirectory = "C:\Users\Public\Documents\MCI\Sito Web"
$f.Title = "Seleft PDF files to merge"
$f.Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
$f.ShowHelp = $true
$f.Multiselect = $true
[void]$f.ShowDialog()
if ($f.Multiselect) { $f.FileNames } else { $f.FileName }
そして私が得る結果は次のとおりです:
C:\Users\Public\Documents\MCI\Sito Web\Insieme>MergePDFInsieme
You chose C:\Users\Public\Documents\MCI\Sito Web\Ristorante\2016-02-08\menugiornaliero.pdf
'C:\Users\Public\Documents\MCI\Sito' is not recognized as an internal or external command, operable program or batch file.
C:\Users\Public\Documents\MCI\Sito Web\Insieme>
は、誰かが助けることができます私は
私は何を持っていることである...文字列を連結することができないのですか?
他のオプションは、値を表示する際に遅延拡張を使用することです。しかし、OPは、変数の最大長が<8191バイトであることを認識する必要があります。 – dbenham
ありがとう、ほぼ完璧です...私はもうエラーは表示されませんが、変数の読み込みが期待通りに機能していないので、 'C:\ Users \ Public \ Documents \ MCI \ Sito Web \ Insieme> MergePDFInsieme.cmd C:\ Users \ Public \ Documents \ MCI \ Sito Web \ Ristorante \ 2016-02を選択した場合は、C:\ Users \ Public \ Documents \ MCI \ Sito Web \ Ristorante \ 2016-02-15 \ menugiornaliero.pdf を選択しました。 -15 \ specialitasettimana.pdf "!Slctn!| C:\ Users \ Public \ Documents \ MCI \ Sito Web \ Ristorante \ 2016-02-15 \ specialitasettimana.pdf" – rodedo
答えを完全に有効にした 'EnableDelayedExpansion'を追加する。 – rodedo