Tuesday, September 8, 2015

Find specific files in all subfolders and copy them to another location

If you have to copy files from multiple subfolders and they do have a certain pattern in their names, you can use a Unix find command, with the parameter -iname (case insensitive).

sudo find ./  -iname'*HCASMC*transcriptID.txt' -exec cp -r {} ~/tquertermous/tquertermous/ \;

For example, in this case transcript featureCounts files from multiple subfolders were copied, thus saving me time from going into each folder and issue a copy command.

sudo find ./  -iname'*HCASMC*transcriptID.txt' -exec cp -v {} ~/tquertermous/tquertermous/ \;
‘./HCASMC_1522_6hr_TGFB/Processed/RAPiD_2_0_0/featureCounts/HCASMC_1522_6hr_TGFB.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_6hr_TGFB.exon.transcriptID.txt’
‘./HCASMC_1522_1hr_PDGF/Processed/RAPiD_2_0_0/featureCounts/HCASMC_1522_1hr_PDGF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_1hr_PDGF.exon.transcriptID.txt’
‘./HCASMC_1522_6hr_TNF/Processed/RAPiD.2_0_0/featureCounts/HCASMC_1522_6hr_TNF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_6hr_TNF.exon.transcriptID.txt’
‘./HCASMC_2989_1hr_PMA/Processed/RAPiD.2_0_0/featureCounts/HCASMC_2989_1hr_PMA.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_1hr_PMA.exon.transcriptID.txt’
‘./HCASMC_2989_1hr_TGFB/Processed/RAPiD_2_0_0/featureCounts/HCASMC_2989_1hr_TGFB.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_1hr_TGFB.exon.transcriptID.txt’
‘./HCASMC_2989_6hr_SF/Processed/RAPiD_2_0_0/featureCounts/HCASMC_2989_6hr_SF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_6hr_SF.exon.transcriptID.txt’
‘./HCASMC_2989_6hr_PDGF/Processed/RAPiD_2_0_0/featureCounts/HCASMC_2989_6hr_PDGF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_6hr_PDGF.exon.transcriptID.txt’
‘./HCASMC_2989_6hr_TNF/Processed/RAPiD.2_0_0/featureCounts/HCASMC_2989_6hr_TNF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_6hr_TNF.exon.transcriptID.txt’
‘./HCASMC_1522_6hr_SF/Processed/RAPiD_2_0_0/featureCounts/HCASMC_1522_6hr_SF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_6hr_SF.exon.transcriptID.txt’
‘./HCASMC_1522_1hr_TGFB/Processed/RAPiD_2_0_0/featureCounts/HCASMC_1522_1hr_TGFB.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_1hr_TGFB.exon.transcriptID.txt’
‘./HCASMC_2989_6hr_TGFB/Processed/RAPiD_2_0_0/featureCounts/HCASMC_2989_6hr_TGFB.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_6hr_TGFB.exon.transcriptID.txt’
‘./HCASMC_1522_1hr_PMA/Processed/RAPiD.2_0_0/featureCounts/HCASMC_1522_1hr_PMA.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_1hr_PMA.exon.transcriptID.txt’
‘./HCASMC_2989_1hr_PDGF/Processed/RAPiD_2_0_0/featureCounts/HCASMC_2989_1hr_PDGF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_2989_1hr_PDGF.exon.transcriptID.txt’
‘./HCASMC_1522_6hr_PDGF/Processed/RAPiD_2_0_0/featureCounts/HCASMC_1522_6hr_PDGF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_6hr_PDGF.exon.transcriptID.txt’
‘./HCASMC_1522_1hr_TNF/Processed/RAPiD.2_0_0/featureCounts/HCASMC_1522_1hr_TNF.exon.transcriptID.txt’ -> ‘/home/mpjanic/tquertermous/tquertermous/HCASMC_1522_1hr_TNF.exon.transcriptID.txt

No comments:

Post a Comment