2017-06-30 12 views
0

Windows環境コマンドプロンプトで一連の複数のファイルを連結する最も良い方法は何ですか? Copy /b file1.mpg+file2.mpg newfile.mpgファイルの連結。

素晴らしいですが、私はそれらの手渡しに参加するための自動バッチプロセスが必要です。

ありがとうございます。

+0

含まれないファイルがありますか? – SomethingDark

+0

いいえ除外する必要があるファイルはありません。 – Vagelism22678

+0

接頭辞 'file'は同じで、ファイル番号は連続していますか?先行ゼロは、アルファソート順を迂回します。 – LotPings

答えて

1

は、ディレクトリ内のファイルの数をカウントすることができますし、ユーザーfor /Lループがそれぞれ1を反復します。

@echo off 

:: Change this to wherever your files are located 
set "source_dir=%userprofile%\Desktop\test_files" 

:: Put the output file in the same directory as this script 
set "target_file=%~dp0output.mpg" 
echo(>%target_file% 

:: Count the number of files in the source directory by searching the output 
:: of dir /b for the number of lines that are not blank 
for /F %%A in ('dir /b %source_dir% ^| find /c /v ""') do set "file_count=%%A" 

:: Iterate over the entire set of files and merge them in order 
for /L %%A in (1,1,%file_count%) do copy /b %target_file%+%source_dir%\file%%A.mpg %target_file% 
+0

1KBのファイルを取得しています...何かが間違っています! – Vagelism22678

+1

@ Vagelism22678 - あなたに私に情報を与えていない場合、どのようにして問題を解決するのか分かりますか? 0バイトのファイルではないということは、_something_が動作していることを意味します。 '@echo off'行を取り除いて再度実行するとどうなりますか? – SomethingDark

+1

私の障害の友達、私はファイルのプレフィックスに 'file'を変更しなければなりませんでした。また、0から反復を開始しました。ありがとうございました! – Vagelism22678

1

ワイルドカードを使用できます。あなたがゼロでファイル名に数字パッドを左にしたくない場合はcopy /b *.mpg newfile.mpg

+0

ありがとうございます。これはファイルを正しい順序で入れますか? 1 ... 2 ... 3 ...など? – Vagelism22678

+0

いいえ' t ...それは89になり、次に9になります... – Vagelism22678

+0

いいえ、それはありません。残念ながら、アルファベット順に表示されます。 – marosu