Hi,
I just need to know a simple command to bulk renaming.
I have hundreds of .DEB files. I want to remove 4%3a from all file names.

example :
old name :
ark-kde4_4%3a4.0.3-0ubuntu4_i386.deb
new name :
ark-kde4_4.0.3-0ubuntu4_i386.deb

I know there is a "rename" command but I don't know it's use.

Thank you

Usually we use the "mv" (move) command to rename a file. Try something like this!

#!/bin/sh

for FILE in $(find . -type f -name '*4%3a*'); do
  NEWNAME=$(echo $FILE|sed s/'4%3a'//)
  mv -v $FILE $NEWNAME
done

If the files are all in one directory, you can run this from in that directory and it should get all of them. It's very basic, so if you run into any problems let us know. It worked on a test run with files formatted like your example.

Hope this helps!
-G

Forgot to add comments!

#!/bin/sh

# first we need a list to work from.  the
# "for" statement will loop through the results
# of our "find" command, using each result in turn
# as "$FILE".  The find command that I used will
# recursive look in subdirectories as well.  You can
# fix that with a flag, or you could use something
# like `ls |grep '4%3a'`
for FILE in $(find . -type f -name '*4%3a*'); do

  # here we use sed to get rid of the unwanted string
  # and store it as "$NEWNAME"
  NEWNAME=$(echo $FILE|sed s/'4%3a'//)

  # here we do the actual work!
  mv -v $FILE $NEWNAME

done

How to use this ? Sorry I don't know.
Because it's not a single line command.

Hmm... well, technically you could run it all on one line like this: for FILE in $(find . -type f -name '*4%3a*'); do NEWNAME=$(echo $FILE|sed s/'4%3a'//); mv -v $FILE $NEWNAME; done but that's kind of ugly :-P

What we have here is called a shell script. What you'll probably want to do is paste the script from above into a text file. Name that text file "myrename.sh" or something easy to remember. Copy it into your ~/bin directory, or if this is a temporary project, save it in the directory where all those files live, and execute it like: $ sh /path/to/myrename.sh I hope that's not too confusing.
-G

commented: Perfect sollution +2

Thank you..
It works as you say.. It's perfectly working

Thanks again

Hi,
I just need to know a simple command to bulk renaming.
I have hundreds of .DEB files. I want to remove 4%3a from all file names.

example :
old name :
ark-kde4_4%3a4.0.3-0ubuntu4_i386.deb
new name :
ark-kde4_4.0.3-0ubuntu4_i386.deb

I know there is a "rename" command but I don't know it's use.

Thank you

you can use the script here
eg usage

# ./script.sh -s "4%3a" -e "" -d "*.deb" # display all files to be renamed
# ./script.sh -s "4%3a" -e "" -d "*.deb"  #remove -d to do actual rename

Thank you ghostdog74,
This one is also userfull