Skip to content

Instantly share code, notes, and snippets.

@ype
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save ype/d61ed97c3993cccd2e0b to your computer and use it in GitHub Desktop.

Select an option

Save ype/d61ed97c3993cccd2e0b to your computer and use it in GitHub Desktop.
Strip all content but day-Week-num from files or folders
#!/bin/bash
# Create an array of the strings we want to remove
remove_string=();
# CAUTION: using * grabs all files and folder in current directory
# you've been warned
for i in *
do
a=$((a+1)); #counts up
#echo first when testing
echo ${remove_string[$a]=${i/([0-9][0-9]_Week_[0-9])/}};
#then comment above, uncomment below
#${remove_string[$a]=${i/([0-9][0-9]_Week_[0-9])/}};
#same as before
echo mv $i ${i/$remove_string[$a]/};
#mv $i ${i/$remove_string[$a]/};
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment