Batch merge multiple text files from different folders - batch-file

I searched this site but all the examples I found were when someone wanted to merge all the files into only 1 file.
I'm on Win 7 x64.
I have 2 folders with 250 text files in each and the filenames (of the text files) across both folders are the same.
Example:
Folder A:
file001.txt
file002.txt
file003.txt
Folder B:
file001.txt
file002.txt
file003.txt
The contents in all these files (and across folders), are different. The filenames themselves vary greatly, too (I just named them like above for example purposes).
Now I want to merge the files from Folder A into the files from folder B.
I want to do this:
Merge FolderA\file001.txt to FolderB\file001.txt
Merge FolderA\file002.txt to FolderB\file002.txt
etc.
So if file001.txt (Folder A) had 500 lines and file001.txt (Folder B) had 300 lines, after the merge file001.txt (Folder B) should have 800 lines.
Right now I'd have to open the file in Folder A, copy all, go to folder B, open the 2nd file, paste, save. For 250 files that's just too much.
Does anybody know of a way to batch merge text files from different folders as explained above?
I'd just love to select all 250 files in folder 1, copy them, paste into folder 2 and have them all merged to their counterparts...but I guess a solution like that doesn't exist. If you know of a program or batch command that does this, I'm all ears.

For %%a in (Folder1\*.txt) do type "%%~a" >> "Folder2\%%~nxa"

Related

How to move files based on characters left to the file extension to a subfolder?

Since I do not have a lot of experience in coding batch files, I would like to ask for some helping hands.
There are multiple files in the source folder. The files list is like this.
ABCD_CH_DEFGH.XLS
ABCD_CH_DEFGH.PDF
ABCD_CH_DEFGH_001_001.XLS
ABCD_CH_DEFGH_001_001.PDF
QWER_DE_OPESADHXCS_002_002.XLS
QWER_DE_OPESADHXCS_002_002.PDF
I would need a batch file which iterates through the files in the source folder and moves only files with the substring _xxx_xxx. to an existing subfolder which are in this case:
ABCD_CH_DEFGH_001_001.XLS
ABCD_CH_DEFGH_001_001.PDF
QWER_DE_OPESADHXCS_002_002.XLS
QWER_DE_OPESADHXCS_002_002.PDF

zip all content in a folder exclude big files

I have a folder containing a lot of files and multiple layers of sub-directories. I would like to zip the folder including the entire content, but exclude all files that is bigger than a certain value, lets say 1000 Mb.
Anyone has any idea about how to accomplish this task?
Thanks!
On Linux, Mac OS X, or Cygwin, Use find to list the files and pipe the file names to zip
find Folder -type f -not -size +1000M | zip foo --names-stdin
This will list recursively all files in Folder whose size is not 1000 Mb or greater and archive using zip into a file named foo.zip.

Bat file to compare files within folder A against folder B

Please can someone help with the below
I have two folders:
C:\FolderA
C:\FolderB
Folder A contains a bunch of files like an archive
Folder B contains the same bunch of files with the same name, however some data within the files may be different.
I want to write a .bat file which uses the diff command to compare all the files from folder A to the files in folder B with the corresponding name (e.g. update0001 against update 0001) and outputs the difference in "C:\Folder C" with each file difference in a separate text output. (e.g one file is called “Error update0001” and another “Error Update0005”
This is a simple way to check the files in two folders and give results.
fc /b "c:\folder a\*.*" "c:\folder b\*.*" >"c:\folder c\results.txt"

Batch - Extract many zip, rename files extracted in a same directory

Hi, I have many zip files located at g:\toto. These zips contain some files. I would like to extract all zip in a same directory (g:\toto\extracted) then rename various files of the zip.
Example 1 :
www_12567.vp.zip : 3 files : alpha.doc, beta.xls, teta.doc
I would like after extraction, files are renamed with the name of the zip
www_12567.vp.alpha.doc, www_12567.vp.beta.xls, www_12567.vp.teta.doc
Example 2 :
www_12.vp.zip : 3 files : al.doc, bea.xls, tta.doc
www_12.vp.al.doc, www_12.vp.bea.xls, www_12.vp.tta.doc
I found this question, but it talks about .txt and the zip contain one file, so, it doesn't work.
Without knowing the contents of the archive you can't know which files to rename, because you are putting them into a directory that may already contain other files.
This, however, would be much easier if there was a dedicated directory to put the files temporarily. Here's how you could use it:
#ECHO OFF
SET "srcdir=G:\toto"
SET "tgtdir=G:\toto\extracted"
SET "tmpdir=G:\toto\extracted-tmp"
FOR %%Z IN ("%srcdir%\*.zip") DO (
unpack "%%Z" with your favourite tool into "%tmpdir%"
FOR %%I IN ("%tmpdir%\*") DO MOVE "%%I" "%tgtdir%\%%~nZ.%%~nxI"
)
Of course, the temporary directory would need to be empty before running the batch file. You could add DEL "%tmpdir%\*" somewhere before the loop to make sure it is.
One other note is, the above assumes that the archives do not contain subdirectories or, at least, that the files are extracted without subdirectories.
UPDATE
If you are using the 7-Zip archiver to work with .zip files, then this is how your extract command might look:
7z e "%%Z" -o"%tmpdir%"
Disclaimer: I'm not an active user of 7-Zip. This is what I used as a reference to come up with the above command:
7-Zip Command-Line Examples

Create a batch file to create multiple folders within many folders

I am trying to create a batch file which will create folders within all sub-folders of a given folder. So for example if it ran in the directory C:\Example, it would create a folder a, b, and c under each of the 20 folders regardless of their name.
It would be much easier to do this automatically rather than copy the .bat file to every individual folder to create the 5 same folders every time with just md.
So far everything I have created has been a disaster, so I'm hoping someone can help me out with this.
for /d %%x in (*) do mkdir "%%x\a" "%%x\b" "%%x\c"

Resources