Forum     

Go Back   Digit Technology Discussion Forum > Community > Tutorials
Register FAQ Calendar Mark Forums Read

Tutorials This section offers tutorials and How to's on just about anything related to computers and IT. Note: All tutorials are courtesy the posters and not verified by Digit


Closed Thread
 
LinkBack (1) Thread Tools Display Modes
Old 09-05-2005, 12:53 AM   1 links from elsewhere to this Post. Click to view. #1 (permalink)
In The Zone
 
sms_solver's Avatar
 
Join Date: Jan 2004
Location: somewhere
Posts: 420
Default Renaming Multiple Files (Tutorial)


A) Renaming multiple files (the WinXP way)

1) Go to the directory in which there are files that you want to rename.
2) Click on View>Thumbnails from the menu in the explorer. This step is not necessary but useful while dealing with graphics file.
3) Select only those files that you want to rename. For that hold down the [Ctrl] key, click on icons of only those files that you want to rename.
4) Position your mouse pointer above any of the selected file. NOw rt-click your mouse, select Rename. Give any name you desired.

5) Now the selected files will have same new name but with different numbered prefix as shown in the figure.



Renaming multiple files and extensions with DOS
1) Under Win9x, Me; Click on Start>Run... Type command to be at DOS prompt. Use cmd under Win2000 or above.
2) Go to the desired directory using "change directory" command.
eg: C:\>cd \Phtotos\MyPhotos.
3) Now (for example) if you wish to change all file's extension from .jpg to something like .tmp. Type the following command. ren *.jpg *.tmp
4) Work complete!! Repeat step 3 with some changes to get the original back.

SOME more examples of "ren"

Example1: ren *in*.* *sn*.* . This will replace the string "in" with "sn" in all those files which have "in" string of current directory.

Example2: ren S*.* p*.*. This will replace all filename starting with letter "S" with "P" regardless of the extension of current directory.

B) Renaming multiple files with IrfanView batch renaming

1) Open IrfanView (this tutorial works best with ver 3.95 or above)
2) Open any one file from the directory having many files that you want to rename.
3) Press the key T to open IrfanView Thumbnail viewer.
4) Select only those files that you want to rename. For that hold down the [Ctrl] key, click on thumbnails of only those files that you want to rename. Press

F2 key. This will open Batch Conversion dialog box.
5) Click on Batch rename radio option to select it. At name pattern textbox give the new name following with hash(#) sign. Keep Output Directory textbox blank, if not the renamed files will be either copied or moved to the defined Output Directory.



(NOTE: If you want e.g. 3 digits in the new renamed name, you have to write "#" thrice in the pattern!
Example: pattern image_### with start index 1 & increment 1 will produce file names image_001, image_002, etc..)

6) Click on Start button to start the renaming process.

SOME more examples to be used at name pattern textbox

Example1: pattern My$N_## with start index 1 and increment 1 will add prefix My to all renamed files along with 2 digit numbering like [b]My$N_01, My$N_02, My$N_03, etc...

Example2: pattern ##_$N_Impo with start index 1 and increment 2 will produce file names like 01_$N_Impo, 03_$N_Impo, 05_$N_Impo, etc....

Example3: pattern $N### with start index 100, increment 10 and replace text (1)=2004 with=2005 will first replace the string 2004 with 2005 in old filenames and then add numbering like $N100, $N110, $N120, $N130, etc....

$N ==> Represents old file name.

==============================
Some USEFUL RENAMING SOFTWARES
==============================
1) Flexible Renamer v6 or above. Flexible Renamer is a file/folder renaming utility, which can use Wildcard or Regular-Expression and Tag-information (MP3, EXIF).

LINK: http://hp.vector.co.jp/authors/VA014830/FlexRena (This is old link, if link is not working, search the google with "Flexible Renamer" or "FlexRena".
DEVELOPED IN: Delphi
TYPE: FREEWARE
SIZE: < 600 KB

2) Flash Renamer v4.6 or above. Shareware software for easy renaming of multiple files & directories.

LINK: http://www.rlvision.com
DEVELOPED IN: Visual Basic
TYPE: SHAREWARE
SIZE: < 700 KB

---------------------TUTORIAL PREPARED BY SMS_SOLVER:08-MAY-2005--------------------
__________________
[ॐ एसएमएस॰सोल्भर ॐ]
sms_solver is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 10-05-2005, 10:07 AM   #2 (permalink)
Apprentice
 
Join Date: Sep 2004
Location: Bangalore, India
Posts: 75
Default

1. Renaming multiple files in Linux, the command line way

rename <pattern> <replace_pattern> <filename(s)>
For example, given the files foo1, ..., foo9, foo10, ..., foo278, the
commands

rename foo foo0 foo?
rename foo foo0 foo??

will turn them into foo001, ..., foo009, foo010, ..., foo278.

And
rename .htm .html *.htm
will fix the extension of your html files.

2. Renumbering Images
Often, images you download from websites may have rubbish characters in their name, and different style of names. Example:
porshe.jpg, red_proshe.bmp, 01-porshe.gif etc.
Following bash script will allow you to turns all of these into something like:
porshe001.jpg, porshe002.jpg, porshe003.jpg and so on.
Not only this, it will also convert them to required image format!. So use it only if you're working on images.

Usage: seqname.bash <prefix> <suffix> <filename(s)>
Example:
seqname.bash porshe .jpg *.bmp
Will convert all bmp files in the directory to jpg format, and will rename them as well (Seqname.bash being the name of the bash script).

So, here is the script:

Code:
#!/bin/bash

#Check for the number of arguments
if [ $# -lt 3 ]; then
   echo "Usage: seqname.bash <prefix> <suffix> file1 [file2 ...]"
   echo "Prefix, Suffix, and filename1 are mandatory parameters."
   exit
fi

#create the temp directory
tmpdir=/tmp/$RANDOM
mkdir $tmpdir
if [ $? != 0 ]; then
   echo "Unable to create temporary directory, exiting."
   exit
fi

#Take out the first name, we use it as a prefix
count=0
prefix1=$1
prefix2="$tmpdir/$1_"
suffix=$2
suffixlen=${#suffix}
negsuffix=$((-$suffixlen))
shift 2

for files in "$@"
do

#Get suitable number of zeroes into the filename
   csize=${#count}
   cdiff=$((4-$csize))
   prefix3=$prefix2
   while [ $cdiff -gt 0 ]; do
      prefix3="$prefix3"0
      cdiff=$(($cdiff-1))     
   done
   newname=${prefix3}${count}${suffix}
   nsuffix=${files:$negsuffix:$suffixlen}

#if the original file has a different suffix than the
#one we specified, try to use convert to convert between
#formats, else simply use mv.

   if [ $nsuffix != $suffix ]; then

      echo "convert ${files} $newname"
      convert ${files} $newname
      if [ $? != 0 ]; then
         echo "Unable to use convert, trying simple move"
   	 echo "mv ${files} $newname"
   	 mv ${files} $newname
      fi

      else
         echo "mv ${files} $newname"
   	 mv ${files} $newname
   fi

   count=$(($count+1))
done

#Now copy the renamed files from the temporary directory to
#our working directory, and delete the temp directory
echo "mv $tmpdir/* ."
mv $tmpdir/* .
echo "rmdir $tmpdir"
rmdir $tmpdir
3. Fixing the case of the filenames and other things.
If you download mp3s/pdfs etc from the web, they will come with names like:
eBooks_-_Manga_-_How_to_Draw_General_Anime_Faces_-_Julie_Dillon.pdf
Psychology_-_Unstoppable_Confidence.pdf

Fixing it by hand is a lot of work. I have a bash script (Actually two versions) which will fix it automatically. It does the following:
Convert all chars to lowercase
Replace all spaces by _ (underscore)
replace all - by _ (underscore)
removes all '
removes all [
etc. This may be or may not be what you want. So running my script on the names:
fixname.bash *.pdf
Gives:
ebooks_manga_how_to_draw_general_anime_faces_julie _dillon.pdf
psychology_unstoppable_confidence.pdf

And here is the script:

Code:
#!/bin/bash

for files in "$@"
do
   newname1=$(echo ${files}  | tr -s "[:blank:]-" _ )
   newname2=$(echo $newname1  | tr "[:upper:]" "[:lower:]")
   newname3=$(echo $newname2  | tr -d "\',\`;()[]" )

   if [ "$files" != "$newname3" ]; then
      echo "mv ${files} ${newname3}"
      mv "${files}" "${newname3}"
   fi
done
I also have a recursive version of this script, which will recursively descend into the subdirectories and do the operation in those files (it will also rename the directories if necessary) as well.


Code:
#!/bin/bash

for files in "$@"
do
   newname1=$(echo ${files}  | tr -s "[:blank:]-" _ )
   newname2=$(echo $newname1  | tr "[:upper:]" "[:lower:]")
   newname3=$(echo $newname2  | tr -d "\',\`;()[]" )

   if [ "$files" != "$newname3" ]; then
      echo "mv ${files} ${newname3}"
      mv "${files}" "${newname3}"
   fi

   if [ -d $newname3 ]; then
      echo "cd $newname3"
      cd $newname3
      echo "sh $0 *"
      sh $0 *
      cd ..
   fi
done
Bye,
Pallav
__________________
Let the games begin!
http://www.ironcode.com/
pallavnawani is offline  
Old 10-05-2005, 10:21 AM   #3 (permalink)
In The Zone
 
Join Date: Dec 2004
Location: Vice City
Posts: 461
Default

I prefer using Rename Master.Its simple.

Anyways thanks for the tut.
__________________
--------------
Lovedeep Wadhwa
cheetah is offline  
Old 10-05-2005, 10:24 AM   #4 (permalink)
 Macboy
 
goobimama's Avatar
 
Join Date: Sep 2004
Location: Goa
Posts: 4,486
Default

for renaming music files, nothing beats TagRename, it just kicks azz...
__________________
I'm like a bird... :)
goobimama is offline  
Old 11-05-2005, 02:46 PM   #5 (permalink)
Apprentice
 
Join Date: Sep 2004
Location: Bangalore, India
Posts: 75
Default

Ok, I searched a bit and found GUI renaming utilities for Linux:


http://freshmeat.net/projects/gprename/
http://www.krename.net/

Enjoy!
Pallav
__________________
Let the games begin!
http://www.ironcode.com/
pallavnawani is offline  
Old 11-05-2005, 05:04 PM   #6 (permalink)
I am Optimus Prime
 
navjotjsingh's Avatar
 
Join Date: Feb 2005
Location: Delhi, India
Posts: 1,919
Default

Excellent tutorial........
navjotjsingh is offline  
Old 14-05-2005, 08:39 PM   #7 (permalink)
Tux
Guest
 
Posts: n/a
Default

Nice TUT man....
But rename master is best
 
Old 05-06-2006, 12:45 PM   #8 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2006
Posts: 5
Smile Re: Renaming Multiple Files (Tutorial)

Hai guys why dont you give a try to 'Namewiz'. Its an excellent software for renaming. you can download the trial version from www.softbytelabs.com. The current version is 4.10. But I find version 3.15 the best and comfortable to work. Just give it a try and let me know.
moxy123 is offline  
Old 06-06-2006, 09:01 PM   #9 (permalink)
In The Zone
 
ashisharya's Avatar
 
Join Date: Jan 2005
Location: Locating....Locating...Access Denied!!!
Posts: 410
Default Re: Renaming Multiple Files (Tutorial)

moxy123 says:
Hai guys why dont you give a try to 'Namewiz'. Its an excellent software for renaming. you can download the trial version from www.softbytelabs.com. The current version is 4.10. But I find version 3.15 the best and comfortable to work. Just give it a try and let me know.

correct..but its feel good when u do it manually
__________________
To follow the path:
look to the master,
follow the master,
walk with the master,
see through the master,
become the master. -Zen
ashisharya is offline  
Old 07-06-2006, 08:59 AM   #10 (permalink)
GaurishSharma.com
 
gary4gar's Avatar
 
Join Date: May 2005
Location: Jaipur
Posts: 4,116
Default Re: Renaming Multiple Files (Tutorial)

good work
for rename instead of right click u can also press f2.

if u khow this spread it.if don't khow it n joy it
gary4gar is offline  
Old 30-07-2006, 02:58 AM   #11 (permalink)
Dreaming Future
 
kin.vachhani's Avatar
 
Join Date: May 2005
Location: \internet\home
Posts: 177
Default Re: Renaming Multiple Files (Tutorial)

this is good one
kin.vachhani is offline  
Old 30-07-2006, 05:05 PM   #12 (permalink)
Right Off the Assembly Line
 
Join Date: Apr 2006
Posts: 7
Default Re: Renaming Multiple Files (Tutorial)

old technique. but still, thanks
pranshu is offline  
Old 30-07-2006, 07:49 PM   #13 (permalink)
The Frozen Nova
 
casanova's Avatar
 
Join Date: Sep 2004
Location: Trespasser in Virtual Land
Posts: 1,641
Default Re: Renaming Multiple Files (Tutorial)

Great tut and thanx for the s/w links.
__________________
I dream of a better tomorrow... where chickens can cross roads and not have their motives questioned.

www.nerdweed.blogspot.com
casanova is offline  
Old 30-07-2006, 08:35 PM   #14 (permalink)
Wise Old Owl
 
JGuru's Avatar
 
Join Date: Dec 2005
Location: Space-time continuum
Posts: 1,646
Default Re: Renaming Multiple Files (Tutorial)

I have written my own program in Java. It renames files in a fly. It can work in Windows,
Linux, Solaris, AIX, UNIX etc., Using the software you can do more customization than
the one XP offers!!
JGuru is offline  
Old 02-08-2006, 07:58 AM   #15 (permalink)
Alpha Geek
 
eagle_y2j's Avatar
 
Join Date: Nov 2004
Location: Himalayas
Posts: 719
Default Re: Renaming Multiple Files (Tutorial)

nice tut d00d nd JGuru can u give me a chance to use ur program
__________________
Registered LINUX USER #438929
eagle_y2j is offline  
Old 02-08-2006, 11:27 AM   #16 (permalink)
The Devil's Advocate
 
iMav's Avatar
 
Join Date: Mar 2006
Location: Masti Ki Paathshaala
Posts: 7,019
Default Re: Renaming Multiple Files (Tutorial)

nice tut bro .... thanx for ur effort ... keep up the good work
__________________
"The problem that shows up with the three red lights on the console is a complex interaction with some very complex parts.” - Robbie Bach

http://beingmanan.com
twitter: manan | Last.FM: manan
iMav is offline  
Old 12-08-2006, 07:08 PM   #17 (permalink)
!FREEWARES!
 
Akshay's Avatar
 
Join Date: Aug 2004
Location: Mumbai
Posts: 1,077
Default Re: Renaming Multiple Files (Tutorial)

Gud tutorial. Try Rename Master
__________________
MBP 13.3";
PC: Core i-5 2400, Intel H67, GSkill 4GB DDR3, Sapphire 6850 Toxic, 1TB HDD, Samsung P2370
Steam (Cod-MW2 only) - akshay81
Akshay is offline  
Old 28-10-2007, 11:01 PM   #18 (permalink)
Right Off the Assembly Line
 
Join Date: Oct 2007
Posts: 1
Default Re: Renaming Multiple Files (Tutorial)

Quote:
Originally Posted by JGuru
I have written my own program in Java. It renames files in a fly. It can work in Windows,
Linux, Solaris, AIX, UNIX etc., Using the software you can do more customization than
the one XP offers!!
Oooh yeah? where's that program wizzy?? i thought you would share a link!!
or you just came here to brag about your little Java program??

Quote:
Originally Posted by pallavnawani
Ok, I searched a bit and found GUI renaming utilities for Linux:


http://freshmeat.net/projects/gprename/
http://www.krename.net/

Enjoy!
Pallav
Hey thanks for the links dude... I was badly looking for them but google just didn't tell.. this is one of the few times google let me down..
Well, your links saved the day.. esp coz i don't know how to write bash files or whateva you call them.. will soon learn that.. and yep.. your tute was helpful too..
cheers

Last edited by silverPolygons; 28-10-2007 at 11:01 PM. Reason: Automerged Doublepost
silverPolygons is offline  
Old 28-10-2007, 11:19 PM   #19 (permalink)
!! RecuZant By Birth !!
 
naveen_reloaded's Avatar
 
Join Date: May 2005
Location: In Everyone`s Heart
Posts: 2,985
Default Re: Renaming Multiple Files (Tutorial)

i was just thinking about it ..and was about to search the web for this one..

thnks .. will try and will do..

thnks
__________________
Know My Thoughts..
Visit my Blog @ www.Urssiva.com
Visit My Tech Blog @ www.CloudTechnica.com
naveen_reloaded is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://www.thinkdigit.com/forum/tutorials/9436-renaming-multiple-files-tutorial.html
Posted By For Type Date
Flexible Renamer DigitNumber() - 楽天ウェブ検索 This thread Refback 29-08-2011 02:55 PM

 
Latest Threads
- by chris
- by icebags
- by Tenida

Advertisement




All times are GMT +5.5. The time now is 01:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2