Easy file renaming?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Moi
QuakeDev Respected
QuakeDev Respected
Posts: 590
Joined: Thu Mar 14, 2002 1:15 am
Has liked: 0
Been liked: 0

Easy file renaming?

Post by Moi » Thu Jan 13, 2005 9:07 am

Hi!

I'm not sure if this is the right forum, since it does not have to do with programming directly...
My problem is: For some short avi-videos I need reverse motion. To do this I'm using avi2bmp, which creates a bunch of BMPs, like:
pic01,pic02,pic03,pic04, etc to pic10

To make the animation play backwards I have to rename the files so
pic10 becomes pic01, pic09 becomes pic02, pic 08 becomes pic03 etc...

Then i just need to BMP2AVI and I get an AVI which plays reversely.

My question is: Can I do this in an easier way? I've been thinking about a DOS-Batch file or a Linux Shell-Script where you just change the name of the 1st and the last file and the script does the rest.
But unfortunatelly thats all beyond my knowledge :(

Can anyone help please? :oops:
Create your own Dreamcast games using the Quake-Engine:
http://quakedev.dcemulation.org/develop/getstarted.htm
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY
Has liked: 0
Been liked: 0

Post by OneThirty8 » Thu Jan 13, 2005 10:39 am

I'm not sure how to do that with a batch file, but it shouldn't be too hard to write a small program to do that. How many bitmap files are we talking about here? I'm reasonably confident that one could write a program that fills an array with the filenames of all of the bitmaps and counts how many there are. Then, it's a simple matter of copying the bitmap to another directory (to avoid overwriting the others) and rename the first one with the name of the last one, and then the name of the second one with the name of the second-to-last file, etc... moving them to a subdirectory as they are renamed so that the last file doesn't get overwritten by the first file, etc.

*edit* I just thought of a way to do it better, actually - give me a few minutes and I'll see what I can do.
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY
Has liked: 0
Been liked: 0

Post by OneThirty8 » Thu Jan 13, 2005 1:07 pm

I believe I've got a working command-line program for you. I just want to clean it up a bit and test it a bit more. Basically, here's what it does:

You tell it the name of the folder that has all of your bitmaps.

It goes through and counts the number of bitmap files.

It goes through again, and figures out what the name of each file should and, appends "*.138" to this name, and writes this name to a text file.

It then reads in the text file one line at a time, and renames (for example) pic01.bmp to pic60.bmp.138. (or, it will be pic500.bmp.138 if there are 500 bitmaps.) The .138 is just so that it doesn't overwrite one picture with another.

Finally, it goes and removes the .138 from all the filenames.

Now, I just have to remove some code that I was using to figure out why it didn't work at first, get it to delete the text file, and double-check that it works. After that, I'll figure out how I'm going to get it to you.
nymus
DC Developer
DC Developer
Posts: 959
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has liked: 1 time
Been liked: 2 times

Post by nymus » Thu Jan 13, 2005 10:45 pm

Does virtualdub have these facilities?
behold the mind
inspired by Dreamcast
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY
Has liked: 0
Been liked: 0

Post by OneThirty8 » Thu Jan 13, 2005 10:57 pm

It might, actually. A lot of video manipulation programs will create a series of bitmaps from an AVI and vice versa. I don't know about reversing the order of them, though.
lo
DCEmu Cool Newbie
DCEmu Cool Newbie
Posts: 16
Joined: Tue Jun 08, 2004 1:43 am
Has liked: 0
Been liked: 0

Post by lo » Fri Jan 14, 2005 6:52 am

mojn Moin,
[hi Moin,]

you can use the Total Commander for that.
it's for win systems.
download:
http://www.ghisler.com/index.htm

??how to??
run TC
go to files
highlight the files (pressed right mouse)
menu: Dateien->Mehrfach-Umbenenn-Tool

settings:

Umbenennmaske Dateiname:
[N1-3][C]

Erweiterung:
[E]

Definiere Z?hler[C]:
Starten bei: 10
Schrittweite: -1
Anzahl Stellen: 2

---------------------------------------------
press Start! to run.....

name:
[N1-3]= name letters 1 till 3 (e.g.:pic..1-2 would be pi)

have sceenshot, but dunno how to upload :-)
hope it works :-)
kind regards oli_lo
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has liked: 0
Been liked: 0
Contact:

Post by GPF » Fri Jan 14, 2005 9:16 am

yeah I use that to Total Commander( previous called Windows Commander) , its an old Norton Commander clone but a lot better has almost everything ftp, zip/unzip ,file viewing, renaming, compare etc, plus it supports plugins.
Moi
QuakeDev Respected
QuakeDev Respected
Posts: 590
Joined: Thu Mar 14, 2002 1:15 am
Has liked: 0
Been liked: 0

Post by Moi » Fri Jan 14, 2005 9:47 am

Big thanks for your help 138, I've sent you a pm.

Glad to see you here lo :)
I'm going to download the commander and try it as well. Thanks for the help.
Hope we'll meet on icq someday again :)
Create your own Dreamcast games using the Quake-Engine:
http://quakedev.dcemulation.org/develop/getstarted.htm
Post Reply