Created
July 23, 2013 07:17
-
-
Save aaronsaunders/6060425 to your computer and use it in GitHub Desktop.
Batch renaming files in iPython
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# infile is 'rename_mapping.txt' tab-sep: oldname newname | |
# ext of file to be replace can be specified | |
with open('rename_mapping.txt', 'r') as fh: | |
map = { line.strip().split()[0]:line.strip().split()[1] for line in fh.readlines() } | |
oldnames = !ls *.fastq.gz | |
for oldname in oldnames: | |
if oldname in map: | |
newname = map[oldname] | |
!mv $oldname $newname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment