Update (2009-10-23): This works well for adding a prefix to files in a folder. To add a suffix to a file read “Renaming files – Adding a suffix to the file name” instead.
Here is a quick way to rename multiple files using bash.
Objective: Rename all image files in a directory in uppercase, to lowercase and append a tn_ prefix.
Step 1: Prepare a working directory
Step 2: Test first – print out all files in lower case
for i in *.jpg; do echo $i | tr [:upper:] [:lower:]; done
Step 3: Test first – print out all files prefixed with tn_ and lower cased
for i in *.jpg; do echo "tn_"$i | tr [:upper:] [:lower:]; done
Step 4: Rename the files in the directory
for i in *.jpg; do mv $i `echo "tn_"$i | tr [:upper:] [:lower:]`; done
This last week I wanted to set up a git repository on dreamhost and came across this article on the Autopragmatic blog. The author provides easy step by step instructions to set up the repository and instructions to work with git. Here I provide a quick summary of what I consider the most important sections, if you’d like to read the original article and get a more in-depth understanding I recommend reading the original article.
Step 1: Compile git on dreamhost (change USER to your username)
tar xzf git-1.6.5.rc1.tar.gz
./configure --prefix=/home/USER/ NO_CURL=1 NO_MMAP=1
Step 2: Automate repository creation. Insert this function in your ~/.bashrc. Change gitdir to point to the path where your repositories will reside.
if [ -z $1 ]; then
echo "usage: $FUNCNAME project-name.git"
git --bare init
git --bare update-server-info
chmod a+x hooks/post-update
Now, what can be done:
1. Create new repository while ssh’d into your dreamhost account:
2. Create new repository remotely
ssh USER@MACHINE newgit repo-name.git
3. Create a new repository remotely. Clone it (check it out). Create file. Add to git. Commit. Push to repository. Make another change. Commit. Push.
ssh email@example.com newgit test.git
git clone ssh://firstname.lastname@example.org/home/asamtani/git/test.git
git add .
git commit -a -m "first commit"
git push --all
git commit -a -m "second commit"
- password will be asked when a new repository is created, a repository is cloned and when a push is made
- when the clone is made a warning will be issued that you are cloning an empty repository
warning: You appear to have cloned an empty repository.
- you need to pass the –all flag when doing the first push or you will get an error like this:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://email@example.com/home/asamtani/git/test.git'
Again, read the original article for a more in depth explanation of what is going on and what more you can do.