Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Created July 20, 2018 01:39
Show Gist options
  • Save icaoberg/b7304803be70047407e44fc6efbdeffe to your computer and use it in GitHub Desktop.
Save icaoberg/b7304803be70047407e44fc6efbdeffe to your computer and use it in GitHub Desktop.
Rename all files in the current directory
#!/bin/bash
#
#$ -j y
#$ -S /bin/bash
#$ -cwd
## the next line selects the partition/queue
#SBATCH -p short1
## the next line selects the number of nodes
#SBATCH -N 1
## the next line selects the number of CPUs
#SBATCH -n 1
## the next line selects the memory size
#SBATCH --mem=1G
## the next line selects the walltime
#SBATCH -t 1:00:00
## the next lines are used to mail the user
## valid type values are BEGIN, END, FAIL, REQUEUE, and ALL (any state change).
##SBATCH --mail-type=ALL
##SBATCH --mail-user=icaoberg@cmu.edu
for FILE in *
do
if [ -f $FILE ]; then
echo mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]'`
mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]'`
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment