Go Back   Forum Care Forums > Development Reference Area > Webmaster Topics

Reply
 
LinkBack Thread Tools Display Modes
Semi-OT: Bulk File Rename
Old
  (#1)
Karl Groves
Guest
 
Posts: n/a
Default Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

I have several folders of pictures from my digital camera. Unfortunately,
they're named stuff like "001.jpg", "002.jpg" within each folder.
So, let's say there was a folder called "dogs", and a folder called "kids"
there would be images named "001.jpg", "002.jpg" in both. Naturally, if I
was to merge both folders together, it just wouldn't work. I'd either need
to overwrite some (thus losing them), not merge files with duplicate names,
or manually rename them.

So, here's the question. Is there any way to bulk rename these files? I'm
open to all ideas, be it desktop app or web script.

TIA


--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Semi-OT: Bulk File Rename
Old
  (#2)
Mark Goodge
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

On Thu, 08 Feb 2007 14:35:11 GMT, Karl Groves put finger to keyboard
and typed:

>I have several folders of pictures from my digital camera. Unfortunately,
>they're named stuff like "001.jpg", "002.jpg" within each folder.
>So, let's say there was a folder called "dogs", and a folder called "kids"
>there would be images named "001.jpg", "002.jpg" in both. Naturally, if I
>was to merge both folders together, it just wouldn't work. I'd either need
>to overwrite some (thus losing them), not merge files with duplicate names,
>or manually rename them.
>
>So, here's the question. Is there any way to bulk rename these files? I'm
>open to all ideas, be it desktop app or web script.


This simple PHP script should do it:

foreach (glob("*/*.jpg") as $filename) {
$newname = str_replace("/","",$filename);
mv($filename,$newname);
}

That will rename all your files in the form

dogs/001.jpg
dogs/002.jpg
kids/001.jpg
kids/002.jpg

to this:

dogs001.jpg
dogs002.jpg
kids001.jpg
kids002.jpg

thus resulting in unique filenames formed from the previous directory
names and image names.

Mark
--
Visit: http://names.orangehedgehog.com - British surname distribution profiles
"And when you play you feel all right"
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#3)
mbstevens
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

On Thu, 08 Feb 2007 14:35:11 +0000, Karl Groves wrote:

> I have several folders of pictures from my digital camera. Unfortunately,
> they're named stuff like "001.jpg", "002.jpg" within each folder.
> So, let's say there was a folder called "dogs", and a folder called "kids"
> there would be images named "001.jpg", "002.jpg" in both. Naturally, if I
> was to merge both folders together, it just wouldn't work. I'd either need
> to overwrite some (thus losing them), not merge files with duplicate names,
> or manually rename them.
>
> So, here's the question. Is there any way to bulk rename these files? I'm
> open to all ideas, be it desktop app or web script.
>
> TIA


If you are on *nix and have the rename command (most do), you can use
something like:

rename 's/\.jpg/DOG\.jpg/' *.jpg

Just do a
man rename
for details.


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#4)
DoobieDo
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

"Karl Groves" <EMAIL REMOVED> wrote in message
news:Xns98D1614BD5D56karlkarlcorecom@199.45.49.11. ..
>I have several folders of pictures from my digital camera. Unfortunately,
> they're named stuff like "001.jpg", "002.jpg" within each folder.
> So, let's say there was a folder called "dogs", and a folder called "kids"
> there would be images named "001.jpg", "002.jpg" in both. Naturally, if I
> was to merge both folders together, it just wouldn't work. I'd either need
> to overwrite some (thus losing them), not merge files with duplicate
> names,
> or manually rename them.
>
> So, here's the question. Is there any way to bulk rename these files? I'm
> open to all ideas, be it desktop app or web script.
>


I use acdsee to arrange and rename. It does series as well as individual
files of course.


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#5)
Andy Dingley
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

On 8 Feb, 14:35, Karl Groves <k...@NOSPAMkarlcore.com> wrote:

> So, here's the question. Is there any way to bulk rename these files?


Learn some simple Unix shell scripting. With a little practice you'll
be writing shell one-liners that do this very easily.

If you're on Windows, first install Cygwin and then see step #1

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#6)
Red E. Kilowatt
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

Karl Groves <EMAIL REMOVED> wrote in message:
Xns98D1614BD5D56karlkarlcorecom@199.45.49.11,

> I have several folders of pictures from my digital camera.
> Unfortunately, they're named stuff like "001.jpg", "002.jpg" within
> each folder.
> So, let's say there was a folder called "dogs", and a folder called
> "kids" there would be images named "001.jpg", "002.jpg" in both.
> Naturally, if I was to merge both folders together, it just wouldn't
> work. I'd either need to overwrite some (thus losing them), not merge
> files with duplicate names, or manually rename them.
>
> So, here's the question. Is there any way to bulk rename these files?
> I'm open to all ideas, be it desktop app or web script.
>
> TIA


http://www.irfanview.com/

It's free and it does lots of stuff, including bulk rename
--
Red


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#7)
John Bokma
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

"Red E. Kilowatt" <EMAIL REMOVED> wrote:

> http://www.irfanview.com/
>
> It's free and it does lots of stuff, including bulk rename


"FREEWARE (for non-commercial use)"

^^^^^^^^^^^^^^

:
:

"IrfanView is provided as freeware, but only for private, non-commercial
use (that means at home)."


<http://www.irfanview.com/main_what_is_engl.htm>

I am sure this is non-commercial use, but in general IrfanView is not
free.

--
John

The walk to the volcano
http://johnbokma.com/mexit/2006/07/0...e-volcano.html
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#8)
Chris F.A. Johnson
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

On 2007-02-08, mbstevens wrote:
> On Thu, 08 Feb 2007 14:35:11 +0000, Karl Groves wrote:
>
>> I have several folders of pictures from my digital camera. Unfortunately,
>> they're named stuff like "001.jpg", "002.jpg" within each folder.
>> So, let's say there was a folder called "dogs", and a folder called "kids"
>> there would be images named "001.jpg", "002.jpg" in both. Naturally, if I
>> was to merge both folders together, it just wouldn't work. I'd either need
>> to overwrite some (thus losing them), not merge files with duplicate names,
>> or manually rename them.
>>
>> So, here's the question. Is there any way to bulk rename these files? I'm
>> open to all ideas, be it desktop app or web script.
>>
>> TIA

>
> If you are on *nix and have the rename command (most do), you can use
> something like:
>
> rename 's/\.jpg/DOG\.jpg/' *.jpg


Note that there at least two different versions of rename, and the
syntax differs.

## Move files from all subdirectories into current directory
## renaming if necessary
for f in */*.jpg
do
nf=${f##*/} ## strip path information
suff=
while [ -f "$nf${suff:+_$suff}" ] ## if the file exists
do
suff=$(( ${suff:-0} + 1 ))
done
mv "$f" "$nf${suff:+_$suff}"
done

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#9)
Red E. Kilowatt
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

John Bokma <EMAIL REMOVED> wrote in message:
Xns98D1739B2E2A3castleamber@130.133.1.4,

> "Red E. Kilowatt" <EMAIL REMOVED> wrote:
>
>> http://www.irfanview.com/
>>
>> It's free and it does lots of stuff, including bulk rename

>
> "FREEWARE (for non-commercial use)"
>
> ^^^^^^^^^^^^^^
>
>>
>>

>
> "IrfanView is provided as freeware, but only for private,
> non-commercial use (that means at home)."
>
>
> <http://www.irfanview.com/main_what_is_engl.htm>
>
> I am sure this is non-commercial use, but in general IrfanView is not
> free.


Picky. Picky.

OK, Freeware for non-commercial use. However, in practice these
conditions are impossible to enforce.
It would be better for him to say that it's freeware, but that all
donations are cheerfully accepted.
--
Red


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Semi-OT: Bulk File Rename
Old
  (#10)
John Bokma
Guest
 
Posts: n/a
Default Re: Semi-OT: Bulk File Rename - 05-14-2007, 01:51 AM

"Chris F.A. Johnson" <EMAIL REMOVED> wrote:

> On 2007-02-08, John Bokma wrote:
>> "Chris F.A. Johnson" <EMAIL REMOVED> wrote:
>>
>> [ IrfanView ]
>>
>>> It is also only available for Windows.

>>
>> I am sure there are programs available for *insert your favourite OS*
>> that can do the renaming thing :-)

>
> Of course there are; I posted one here.


:-D.

I would probably use Perl ;-)

--
John

The spiny lizard relaxing
http://johnbokma.com/mexit/2006/12/3...-relaxing.html
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

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





Contact Us - Forum Care Forums - Archive - Top