Skip to content

Instantly share code, notes, and snippets.

@thvasilo
Last active January 22, 2018 17:07
Show Gist options
  • Save thvasilo/ca76a6f40e1ec854beb3257849ffa8c3 to your computer and use it in GitHub Desktop.
Save thvasilo/ca76a6f40e1ec854beb3257849ffa8c3 to your computer and use it in GitHub Desktop.
Using mmv and GNU parallel to easily rename bunches of files under mulitple dirs
# My situation: I have a bunch of experiments nested under parameter dirs
# 10/ 20/ 30/ ...
# Each experiment dir has some experiment files, trailing _X indicates X repeat of experiment
# specific dataset
# ls 10/
# dataset1_0.csv dataset2_0.csv dataset1_1.csv dataset2_1.csv
# Problem: I want to rename all the <datasetname>_1.csv files to <datasetname>_2.csv
# Solution: parallel & mmv!
# Use GNU parallel because it has a nicer syntax than bash for loops
parallel -j -q 2 mmv {1}/"*_1.csv" {1}/"#1_2.csv" ::: {10..100..10}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment