Game authors and players, please read this thread!

Author Topic: Looking for batch file renamer  (Read 1158 times)  Share 

Gregjazz

    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
  • Gregjazz worked on a game that was nominated for an AGS Award!Gregjazz worked on a game that won an AGS Award!
Looking for batch file renamer
« on: 03 May 2009, 01:56 »
People on this forum have been so helpful to me in the past, I thought I'd try my luck yet again.

I'm looking for a batch file renamer which will rename files based on rules. For example:

If the file contains a "D2" in the file name, add "01" to the beginning of the file name.
If the file contains a "D#2" in the file name, add "02" to the beginning of the file name.

The interface might not be set up this way, but as long as it can do this task, that's all I ask for.

And so forth. I found the software "Sophisticated Rename" which allows me to do this. However, I don't want to pay $60 in case there is other software out there that does this.

Leon

  • Image Updaters
  • Seems like the Thumb can't get a signal here.
    • I can help with play testing
    •  
    • I can help with translating
    •  
Re: Looking for batch file renamer
« Reply #1 on: 03 May 2009, 02:50 »
I use the BulkRenameUtility.
It's free, easy to use and has endless posibilities. You can even do some basic scripting with it for repeated actions or sequenced renaming (first remove ... then with the remainder add ... etc.)
Ultimate Game Solutions - 'cause there's a solution for everything

AGA

  • Adventure Game Aficionado
  • Administrator
  • AdventureX Crew
  • Mittens Monarch
  • ¡Qué alí­vio!
  • AGA worked on a game that was nominated for an AGS Award!
Re: Looking for batch file renamer
« Reply #2 on: 03 May 2009, 03:02 »
I use AF5. It has a few more sophisticated functions that I never bothered working out how to use, so it might work.

Gregjazz

    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
  • Gregjazz worked on a game that was nominated for an AGS Award!Gregjazz worked on a game that won an AGS Award!
Re: Looking for batch file renamer
« Reply #3 on: 03 May 2009, 03:21 »
I tried both, but I still can't do what I want.

For example, BulkRenameUtility--there's only one match/replace box. I need 30 separate matches/replaces for different strings.

Well, it's not even a match/replace, but it's more like a match/insert. Like in my example, "if the file name contains 'D2' (which it may not), insert '01' at the beginning of the file name". But it not only needs to do just that, but have many other insert strings depending on the match.
« Last Edit: 03 May 2009, 03:22 by Gregjazz »

Trent R

  • "I am the weapon" -Richard Cypher
    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
Re: Looking for batch file renamer
« Reply #4 on: 03 May 2009, 04:58 »
Can't you use a command prompt to do this?

Actually, now that I think about it, your needs are probably too specific to use cmd.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.

Current Project: The Wanderer
On Hold: Hero of the Rune

densming

  • It's always less than a week till Friday!
    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
Re: Looking for batch file renamer
« Reply #5 on: 03 May 2009, 05:31 »
I'm assuming this is Windows?  If so, you could use a for loop on the command prompt:

for %f in (*d2*) do ren "%f" "01%f"
for %f in (*d#2*) do ren "%f" "02%f"
...etc...

Be careful though, if you run this from a batch file (as opposed to directly from the command prompt), you'll need to use double percent signs:

for %%f in (*d2*) do ren "%%f" "01%%f"
for %%f in (*d#2*) do ren "%%f" "02%%f"
..etc..

Gregjazz

    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
  • Gregjazz worked on a game that was nominated for an AGS Award!Gregjazz worked on a game that won an AGS Award!
Re: Looking for batch file renamer
« Reply #6 on: 03 May 2009, 05:48 »
Thanks for the batch file help, densming.

After trying demos of at least 12 products, I just found this piece of software: http://www.coolutils.com/Article.php?Article=RenameFiles&from=AdWordsRenameFiles

It does exactly what I need, and also includes a scripting language as well.

Nikolas

  • just me in awful resolution
Re: Looking for batch file renamer
« Reply #7 on: 03 May 2009, 17:18 »
I think that what you SEEM to be wanting to do is very very interesting. Share more, share more, share mutli more stuff please!  :D

Gregjazz

    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
  • Gregjazz worked on a game that was nominated for an AGS Award!Gregjazz worked on a game that won an AGS Award!
Re: Looking for batch file renamer
« Reply #8 on: 04 May 2009, 01:41 »
Basically what I'm doing is renaming sample file names from including a MIDI note name to having a numeric value as a suffix. That way when they get sorted alphabetically, they are sorted chromatically. This makes mapping sample libraries a LOT faster and easier.

BOYD1981

  • Dave Gilbert Appreciation Society
Re: Looking for batch file renamer
« Reply #9 on: 04 May 2009, 02:04 »
i used to use a brilliantly handy app called RenameWiz, it isn't free but i'm not sure if the trial version limits any functionality.
i tried some other batch renamers recently, but they were all crappy compared to RenameWiz.
http://www.renamewiz.com/

Limey Lizard, Waste Wizard!
011011010110000101100100011001010010000 001111001011011110111010100100000011011 00011011110110111101101011

Gregjazz

    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
  • Gregjazz worked on a game that was nominated for an AGS Award!Gregjazz worked on a game that won an AGS Award!
Re: Looking for batch file renamer
« Reply #10 on: 04 May 2009, 02:53 »
I'm assuming this is Windows?  If so, you could use a for loop on the command prompt:

for %f in (*d2*) do ren "%f" "01%f"
for %f in (*d#2*) do ren "%f" "02%f"
...etc...

Be careful though, if you run this from a batch file (as opposed to directly from the command prompt), you'll need to use double percent signs:

for %%f in (*d2*) do ren "%%f" "01%%f"
for %%f in (*d#2*) do ren "%%f" "02%%f"
..etc..

I tried this, and it works to some degree. On a few files it placed "01 01" at the beginning rather than just "01". It shouldn't be finding multiple matches within each individual file name...

Snarky

  • Local Moderator
  • Mittens Baronet
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Looking for batch file renamer
« Reply #11 on: 04 May 2009, 03:41 »
I think computer pros generally do this kind of thing using regular expressions (kind of advanced pattern-matching). Perl is supposed to be pretty good for regex stuff, so you could install a Perl engine for windows and write a script in that language to do exactly what you want.

...Yeah, I know, it doesn't exactly sound quick and easy to me either.

Re: Looking for batch file renamer
« Reply #12 on: 05 May 2009, 20:06 »
I think computer pros generally do this kind of thing using regular expressions (kind of advanced pattern-matching). Perl is supposed to be pretty good for regex stuff, so you could install a Perl engine for windows and write a script in that language to do exactly what you want.

...Yeah, I know, it doesn't exactly sound quick and easy to me either.
It does sound quick and easy to me. Perl is awesome for that purpose. Only problem is that when you want to do the same thing in six months and want to change the script a bit, you have to write it from scratch because you have no idea what the code does you wrote six months ago. ;)

Snarky

  • Local Moderator
  • Mittens Baronet
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Looking for batch file renamer
« Reply #13 on: 06 May 2009, 20:01 »
Installing a Perl engine, learning a new programming language, and programming the rename operations yourself on the command line in generally incomprehensible syntax sounds easy?

Re: Looking for batch file renamer
« Reply #14 on: 07 May 2009, 08:05 »
Installing a Perl engine, learning a new programming language, and programming the rename operations yourself on the command line in generally incomprehensible syntax sounds easy?
Of course it does?
Installing is pressing the next button couple of times. Learning new programming language is easy if you know how to program. And then just google a ready made code for renaming files. ;)

monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: Looking for batch file renamer
« Reply #15 on: 07 May 2009, 18:30 »
And then just google a ready made code for renaming files. ;)

Why not just do that for the batch file route? That avoids having to install Perl, worrying about having to learn the code, etc. and so-forth.

The batch file doesn't really have regex, but is there a reason to defer to a full programming language which Greg likely doesn't already have installed?

How many of the files were having duplicate prefixes added?

Would something like this work?

[code]@echo off
SetLocal EnableDelayedExpansion
for %%f in (*d2*) do (
set name=%%f
set str=!name:~0,2!
if not !str!==01 ren "%%f" "01%%f"
)
for %%f in (*d#2*) do (
set name=%%f
set str=!name:~0,2!
if not !str!==02 ren "%%f" "02%%f"
)
EndLocal[/code]

I'm not sure if you can do substrings on the %%f, but that makes sure that each file only gets the prefix added once.

Edit: Apparently this requires delayed expansion. I've changed the code (tested now lol). I couldn't figure out any way to take a substring from %%f. And I was getting an error trying to use the substring directly in the if statement so that's why I put the additional variable.

Edit: Just wanted to put some info here from PMs between myself and Greg. For anyone unaware batch files treat very few things in a case sensitive manner so any patterns used by this batch file would have to be unique. One other option is that for Greg's use the patterns are always separated by whitespace. So if you have a whitespace character on either side you could make the pattern something such as:

[code]for %%f in ("* d2 *") do ([/code]

You must enclose this pattern in quotes or it won't read the whitespace as part of the pattern. Just FYI for anyone reading this. ;)
« Last Edit: 16 May 2009, 03:25 by monkey_05_06 »
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

Gregjazz

    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with voice acting
    •  
  • Gregjazz worked on a game that was nominated for an AGS Award!Gregjazz worked on a game that won an AGS Award!
Re: Looking for batch file renamer
« Reply #16 on: 07 May 2009, 21:09 »
Densming's batch file worked, but we weren't able to find a way to disable 8.3 short file names, since I'm dealing with long file names only.

Basically with a few files it would "find the same file" more than once and execute the task multiple times, which gave the wrong results.

monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: Looking for batch file renamer
« Reply #17 on: 08 May 2009, 06:36 »
Did you test the modifications I made? That should prevent it from detecting the same files multiple times. If the file name already starts with "01" or "02" (or whatever) then it just gets ignored. Unless of course it contained multiple patterns...is that the problem?
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

goldensox

  • Awesomeface.jpg
    • I can help with backgrounds
    •  
    • I can help with play testing
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Looking for batch file renamer
« Reply #18 on: 09 May 2009, 07:25 »
I use RenomearTudo. It sure rename everthing, make smart sequences and all. It's the photoshop of the filenames. :=
Faster than a doughnut, stronger than cardboard.
                                                                    -Wario