Compare files in VSCode and output the differences automatically to a separate file - bash

I use VSCode to compare 2 large csv files (each is almost 140k lines).. I have used >compare active file with..
I want to extract only the difference to clean it up manually.
How can I do that?
Is there any extension or tip will help me on this?

Related

How to apply a prediffer to WinMerge such that it runs on all files in the diff?

TL;DR: How can I automatically apply PrediffLineFilter on all diff results, not manually on only the open file?
WinMerge 2.16.4.0 supports using plugin prediffers to, among things, diff while ignoring items that meet conditions specified with a regular expression*. However it appears you must manually apply the prediff after you perform the diff (huh?) and on each and every individual file if it doesn't match a file filter. The help manual indicates the file filter for PrediffLineFilter.sct is *.txt and gives no guide to changing it.
I have thousands of files where the only difference might be a server name which follows a predictable pattern. (Example: server01, server02, etc.) I have figured out the regex for that pattern and the manual application of PrediffLineFilter after a diff works. But I can't be doing that on thousands of files.
How can I automatically apply PrediffLineFilter on all diff results, not manually on only the open file? I only want to see the files where the differences are meaningful.
*Learned this thanks to WinMerge : how to ignore specific words in a comparison?
In your winmerge installation folder, go to MergePlugins then edit the PrediffLineFilter.sct. Then change the return of get_PluginFileFilters to files you want this plugin to work on. For example you want this plugin to work on html and txt files:
Function get_PluginFileFilters()
get_PluginFileFilters = "\.html$;\.txt$"
End Function
After you have made these changes, select all the files on your folder compare window then right click > Plugin Settings > Prediffer Settings > Auto Prediffer, then refresh.
Btw, in the later versions(2.16.10) you can do this in the Plugin Settings window.

How to replace all files with a specific pixel size, and keep their names?

I have a .png file and a folder with multiple folders in it, that all contain multiple .png files, e.g. '1.png', '2.png' and so on. What I'd like to do is to replace the contents of all those files to the first named file, but keep their names.
I'm pretty sure this is doable and I think I found an answer to do this in one folder using command prompt on Windows, but I'd also like to only replace files that have a specific file size (in pixels, and not the same size as the file I'm replacing them to, just a specific file size).
I prefer to do this simply using a batch file, so if anyone can help that'd be appreciated a lot. If it's not possible to meet the file size criteria with a batch file, but it is possible to do this for a whole directory tree with .png files, that gets me a long way as well.
Thank you in advance!
Edit: In the comments Stephan mentioned you can't get the pixel size of a file, so it turns out this isn't possible. I'm not going to bother with an external application.

Merge two text files

I'm using Windows and Notepad++ to separate file in txt. I have 2 files which is I have to merge it side by side or line by line for my data analysis.
Here is the example:
file1.txt
Abcdefghijk
abcdefghijk
file2.txt
123456
123456
then the output I want is like this:
Abcdefghijk123456
abcdefghijk123456
in the next file or output file. Does anybody here know how to do this?
Your question answered here by TheMadTechnician. Using powershell, you should take both source files (1 and 2) as arrays of lines. Then comes simple cycle, like "merge line x from file1 with line x from file2 as long you have some lines in file1".
Unfortunately its impossible with pure cmd.
#riki.. you could also write a batch program to do this pro grammatically. There should probably be no limit over the number of lines.
It may depend on the number of lines you're having in each files. I suggest to copy paste the same if it is less than 50 lines.
Otherwise,
use some powerful languages like python, c,php etc. And make it run before performing data analysis.
There is a free utility you can download and run on your computer, called txtcollector. I read about it here. I used it because I had a whole folder of files to concatenate. It was a breeze. The only slight imperfection I noticed was that I couldn't paste in the path to the specific folder in the first step (choosing the folder where the files to be concatenated were). However, I could do this when choosing where to save the result.

Handle single files while extracting tar.gz

I am having a huge .tgz file which is further structured inside like this:
./RandomFoldername1/file1
./RandomFoldername1/file2
./RandomFoldername2/file1
./RandomFoldername2/file2
etc
What I want to do is having each individual file extracted to standard output so that I can pipe it afterwards to another command. While doing this, I also need to get the RandomFoldername name and file name so that I can deal with them properly from within the second command.
Till now the options I have are
to either extract all of the tarball and deal with the structured files that I will be having, which is not an option since the extracted tar doesn't fit into the hard drive
Make a loop that pattern match each file and extract one file at time. This option although that solves the problem, is too slow because the tarball is sweeped each time for only one file.
While searching on how to solve this, I've started to fear that there is no better alternative to this.
Using tar the tool I don't believe you have any other options.
Using a tar library for some language of your choice should allow you to do what you want though as it should let you iterate over the entries in the tarball one-by-one and allow you to extract/pipe/etc. each file one-by-one as necessary.

DUnit Compare Two Text Files and show Diff

Is there a way to compare two text files and show the diff if they are not identical in dunit?
The easy start is to read them to TStringList, however the code for comparing two text file is much more complicated, and the gui in the DUnitGui is not sufficient for this.
Any idea? suggestion?
There is a nice little unit that comes with some examples called TDiff, this is available from http://angusj.com/delphi/ and will allow you to compare 2 files and see the differences, it also allows for merging.
It is a very simple Utility that you can download the entire source for.

Resources