How to extract files from multiple folders - windows

I got one problem i got like 20000 folders in every folder is like 10 files .txt
I need to extract from every folder specific text file which has a name Names.txt
How can I do it, to get 20000 files Names.txt in one folder?

Related

Replace files in multiple folders, whose name includes destination folder name

I have very little experience with the command line and I'm trying to do something very complicated (to me).
I have a directory with A LOT of subfolders and files in them. All file names contain the parent folder name, e.g.:
Folder1
data_Folder1.csv
other_file_Folder1.csv
Folder2
data_Folder2.csv
other_file_Folder2.csv
In another folder (all in one directory), I have a new version of all the data_FolderX.csv files and I need to replace them in the original folders. I cannot give them another name because of later analyses. Is there a way to replace the files in the original folders with the new version, in the command line?
I tried this Replacing a file into multiple folders/subdirectories but didn't work for me. Given that I have many .csv files in the derectories, I don't want to replace them all, so I don't think I should do it based on the file extension. I would also like to note that the name "FolderX" contains several other _, so in principal, I want to replace the .csv file starting with data in the FolderX.
Can anyone help?
Thanks in advance!

how do i combine txt file from a list of file emplacement

i have a problem, i used "everything" to extract every txt file from a specific directory so that i can merge them. But on emeditor i don't find a way to merge file from a list of localisation.
Here what the everything file look like:
E:\Main directory\subdirectory 1\file.txt
E:\Main directory\subdirectory 2\file.txt
E:\Main directory\subdirectory 3\file.txt
E:\Main directory\subdirectory 4\file.txt
The list goes over 40k location. is there a way to use a program to read all the location in the text file and combine them ?
Also, the subdirectory has other txt file that i don't want to so i can't just merge all txt file from the main. Another thing is that there are variation of the "file.txt" like "Files.txt" for example.

cat multiple files in multiple folders via a loop

I have a set of files which have fastq.gz inputs (R3003_C0UH3ACXX_ATTACTCG_L005_R1_001.fastq.gz ) In these files the RXXXX numbers are not sequential. However I got all the folder names whch begin with R in a txt file , one in each line. Each folder has different number of *_R1 and *_R2 files. I would like to merge them and I have used cat *_R1.fastq.gz and *_R2.fastq.gz indiviually to do this .But I have 500 samples and it is impossible to run them all like this by going into each individual folder and doing cat. How do I get to open each folder in the txt file, run cat to get the final RXXX.R1.fastq.gz and RXXXX.R2.fastq.gz for each folder with a loop?
My file name is R3.txt which lists the RXXX files and I tried
for i in cat R3 ; do cat $i*R1*.fastq.gz >$i\.R1.fastq.gz; done
But it doesn't do what I hoping

Bash script for editing multiple text files

I would like some guide and help for this:
I have a text file with names listed in it. I will call it “source file”
I have multiple text files scattered in folders and sub folders
I would like to know how to make a script that would automatically add SPECIFIC LINE to every text file (in subfolders of chosen target folder) that contains exact name listed in “source file”
More detailed/Example:
I have a names.txt that contains many names. I want to find all the text files in target folder and it’s subfolders that contains names listed in names.txt and in those files automatically add “FALSE” line (in front or after specific existing line).

I want to move 100 out of 1Million files of a particular extension to a target folder in linux

I have a folder(/DIR/SRC) containing 1 Million files with different types of extensions.
I would like to pick a particular extension files from the SRC folder, may be 1000 at a time and move to a target folder which is at /DIR/TGT.
The file name has the format 1234_XXXX-XXXX_TIMESTAMP.ext
Try this one:
mv `ls -1 *.your_ext|tail -n 100` /TARGETDIR
I didn't test it, but in this way it should work.
If you want the latest 100 or alphabetically the first 100 (or, or, or,...) you can change the ls-command.
This will move all files with .your_extension in current folder to your new path
mv *.your_ext your/new/path

Resources