Mass Sequential Rename
This program can do the same thing as krename of KDE, for Nautilus in Gnome. It modifies selected files with sequential number.
#!/bin/bash
# Nautilus script for mass file renaming.
# Created by Ben(AT)Fadshop.net. http://benincampus.blogspot.com .Mar 29, 2009
# Based on http://jrfonseca.blogspot.com/2006/05/mass-renaming-in-nautilus.html
set -e
TITLE=`basename "$0"`
EXPR=""
EXPR=`zenity --title "$TITLE - expression" --entry --text "Specify the Prefix for modifying the filenames." --entry-text "$EXPR"` || exit
NUM=0
IFS=$'\n'
for FILE in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
cd "`dirname "$FILE"`"
filename=""`basename "$FILE"`""
EXT="${filename/*./}"
mv ""`basename "$FILE"`"" "$EXPR$NUM.$EXT"
NUM=$((NUM+1))
done
Create a new file ~/.gnome2/nautilus-scripts/Mass Sequential Rename with the content above and change it as executable. Then in Nautilus you can select several files and right click. In the context menu there is a Script->Mass Sequential Rename selection to run the script and rename the files.
4 Comments:
FREE TIBET!
Nice script, it has been very useful to me, but I'm having a problem and would like your help.
Using the script as nautilus script (menu context) it works fine, but I don't know how to use it in terminal. I run "./script filename1 filename2 filename3", enter the prefix, but nothing happens.
I already realize what happened. ^_^
To run the script as I wanted is needed to replace $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS with $*, and use "./script /path/filename1 /path/filename2 /path/filename3".
Good job, Cristiano.
<< Home