質問

I'm trying to use diff3 in this way

diff3 options... mine older yours

My problem is that I probably can't use it, since all my 3 files contain a "dash" within. The manual mentions: At most one of these three file names may be `-', which tells diff3 to read the standard input for that file.

so I probably have to rename filenames before running diff3.

If you know for a better solution or a workaround, please let me know about. Thank you!

役に立ちましたか?

解決

At most one of these three file names may be `-', which tells diff3 to read the standard input for that file.

It does not state, that your filenames should not contain dash symbols. It simply says, that if you want to, you can put - instead of one of the names, in which case the standard input will be read instead of reading one of the files.

So, you can have as many dashes in your filenames as you like and diff3 should work just fine.

However, on Windows putting filenames in "" for escaping space characters does not work, and I failed to find a suitable workaround. However, you can automatize the process of renaming files (if the files are relatively small, this would not even be too inefficient):

@echo off

copy %1 tempfile_1.txt
copy %2 tempfile_2.txt
copy %3 tempfile_3.txt

"C:\Program Files (x86)\KDiff3\bin\diff3.exe" -E tempfile_1.txt tempfile_2.txt tempfile_3.txt
del tempfile_1.txt tempfile_2.txt tempfile_3.txt

Put this in a file like diff3.cmd, then run diff3.cmd "first file.txt" "second file.txt" "third file.txt".

P.S. Moving files would be more efficient (if they are on the same disk volume as the script, which they are not in your case), you could even move them back to where they were initially, but for some time they would not be present at their original folder.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top