Overview

This page is designed to give minor examples, and general principles for renaming multiple files at once from the command line based on given criteria and wildcards. Makes use of a command line for loop and the sed command.

Renaming multiple fastq files

  1. Assume you have downloaded multiple fastq files which are of format: Samplename-Lane-runID-etc-etc.fastq
  2. for file in *.fastq;do new_name=$(echo $file|sed 's/-*//'); mv $file $new_name;done
    • Generic explanation:
    • for "variable name" in "files to consider"; do "new variable name"=$(echo $"variable name"|sed 's/what to find/what to replace/');mv $"new variable name" $"variable name";done

-- Main.DanielDeatherage - 21 Aug 2014

Edit | Attach | Watch | Print version | History: r6 | r4 < r3 < r2 < r1 | Backlinks | Raw View | More topic actions...

 Barrick Lab  >  ComputationList  >  ProtocolsMassRename

Contributors to this topic Edit topic DanielDeatherage
Topic revision: r1 - 2014-08-21 - 21:56:08 - Main.DanielDeatherage
 
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright ©2024 Barrick Lab contributing authors. Ideas, requests, problems? Send feedback