Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: i need to bulk rename media files ($20 bounty!)  (Read 2218 times)

0 Members and 1 Guest are viewing this topic.

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
i need to bulk rename media files ($20 bounty!)
« on: April 06, 2020, 11:30:54 pm »
hi guys,

i need to bulk rename rom media files to the game description per the xml.  can anyone point me in the direction of an app or batch file that might work? 

for instance, rom name dkong, all supporting media also called dkong.  in the xml, the description line is obviously “donkey kong”. 

app or batch file would parse the xml, find the rom name and then rename the media files found with that same name to the name in the description field of the xml.

any thoughts on possibility?  anyone want to write a batch file that would do it and make $20 bucks?

pbj

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10875
  • Last login:April 23, 2024, 11:27:54 pm
  • Obey.
    • The Chris Burke Band
Re: i need to bulk rename media files ($20 bounty!)
« Reply #1 on: April 06, 2020, 11:43:26 pm »
This will break everything. 

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #2 on: April 07, 2020, 12:16:48 am »
not in the front end i am using in my pinball cabinet.  i have been doing so manually and the games i’ve changed are working.  only 900 more to go (hence the automation i’m hoping for).

Zebidee

  • Trade Count: (+9)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3255
  • Last login:Yesterday at 01:18:46 am
Re: i need to bulk rename media files ($20 bounty!)
« Reply #3 on: April 07, 2020, 12:47:37 am »
You FE must be very primitive if it can't match the media to the romname. If so, maybe you should look for another FE? What FE are you using anyway?

PBJ is right - renaming all the rom files (or the media files, the names should match) will break everything, except maybe your brute-force work-around.

Most modern FEs can read/parse the xml to allow this to happen seamlessly. Those that don't (eg older FEs don't work with modern mame xml formats) should be able to read a DAT file with essentially the same information. Any FE from the past 20 years should be able to do this.

In Mamewah, for example, you would choose to create game lists according to "rom_folder_vs_dat_file", which would then give you the game description in long form eg "Donkey Kong", and match that to the romname eg "dkong" for media, launching, etc.

I think it would be easier to make a DAT file by hand than to rename all the roms. I've done it a few times for small sets.

Another way about it is to use a utility like "Romlister" which can parse the xml files and rom sets to create game lists for use in a bunch of different front ends, all without renaming any roms.
https://www.waste.org/~winkles/ROMLister/

Maybe you need some advice specific to the FE you are using... oh yeah, what is it?
Check out my completed projects!


tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #4 on: April 07, 2020, 02:54:04 am »
i’m using pinballY for the build

nexusmtz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 489
  • Last login:June 01, 2022, 03:14:22 am
Re: i need to bulk rename media files ($20 bounty!)
« Reply #5 on: April 07, 2020, 04:21:32 am »
Ignoring whether it's the right thing to do, I'll get you started. I won't spend any real time on it, since you probably don't want quite what you're asking for (given that dkong's description isn't Donkey Kong, rather it's Donkey Kong (US set 1)).

This is a couple powershell commands to read/parse mame's xml and step through each rom, looking for (and renaming) matching files.

Code: [Select]
$mamexml=[xml](gc mame0220.xml)
$mamexml.mame.machine|%{$n=$_.name;$d=$_.description;if($n -cne $d){gci "$n.*"|%{$_.name;rni -path $_ -newname ($_.name -replace $n,$d)}}}

Test it on a small subset of your (backed up) roms and find out if it does what you want. It took my machine a few minutes to parse the xml, which is why I put that on its own line. The walkthrough also takes several minutes because it looks for every rom. It prints the names of the files that it finds, so you should be able to tell if it's doing anything.
« Last Edit: April 07, 2020, 04:34:27 am by nexusmtz »

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #6 on: April 07, 2020, 11:21:31 am »
thanks nexus, itching to give this a go!

which folder should i be in when running the command?

meaning, example, should i have a sample of videos and roms in the same folder, open a power shell command in that folder and run the commands?

thanks again for your help, can’t wait to try it out!

abispac

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1526
  • Last login:Yesterday at 12:26:13 am
Re: i need to bulk rename media files ($20 bounty!)
« Reply #7 on: April 07, 2020, 12:03:19 pm »
hi guys,

i need to bulk rename rom media files to the game description per the xml.  can anyone point me in the direction of an app or batch file that might work? 

for instance, rom name dkong, all supporting media also called dkong.  in the xml, the description line is obviously “donkey kong”. 

app or batch file would parse the xml, find the rom name and then rename the media files found with that same name to the name in the description field of the xml.

any thoughts on possibility?  anyone want to write a batch file that would do it and make $20 bucks?
Can i ask why would you want to do something like this? usually front ends dont care about the media naming, i use hyperspin and it does not care, even retropie does not care.

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #8 on: April 07, 2020, 12:12:40 pm »
from what i gather in pinballY, the xml is parsed and in the game info/setup screen, it shows the rom name, the game description and then the “media name”.

the games in the wheel are alphabetized by description.  the media name seems to default to the description.  thing is, all the media is named per the rom file.  the only way for me to get the media to display is to go into each game set up window and change the media name back to the rom file name.  and i don’t want to do this for 900 vertical roms :)

nexusmtz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 489
  • Last login:June 01, 2022, 03:14:22 am
Re: i need to bulk rename media files ($20 bounty!)
« Reply #9 on: April 07, 2020, 12:25:41 pm »
...meaning, example, should i have a sample of videos and roms in the same folder, open a power shell command in that folder and run the commands?
Yes, the get-childitem command isn't looking in subdirectories currently, so whatever directory you're in, that's where it will look for the files. The xml will have to be in that same directory unless you provide the full path to the gc (get-content) command like (gc "c:\mymamedir\mame0220.xml")

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #10 on: April 07, 2020, 02:26:29 pm »
thanks nexus.  i am running both commands but it doesn’t dmd esm to be doing anything?

nexusmtz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 489
  • Last login:June 01, 2022, 03:14:22 am
Re: i need to bulk rename media files ($20 bounty!)
« Reply #11 on: April 07, 2020, 11:32:39 pm »
The first command doesn't output anything. If you want to know if it worked, wait for it to finish and enter $mamexml.mame
That should look like the following:
Code: [Select]
PS c:\games\mame0220b_64bit> $mamexml.mame

build            debug mameconfig machine
-----            ----- ---------- -------
0.220 (mame0220) no    10         {005, 100lions, 10yard, 10yard85...}

The second command will be harder to troubleshoot, but if you have dkong.zip in the directory, it should (after several minutes) rename the file to Donkey Kong (US set 1).zip

Show me a directory listing of your test directory and I'll try with the same file names. Also, what version of OS, MAME, and powershell are you using? (get-host|select version) I have 5.1, but the code doesn't do anything fancy.

If you have an older version of MAME, 'machine' used to be 'game', so you'd need to use $mamexml.mame.game instead of $mamexml.mame.machine.

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #12 on: April 08, 2020, 12:27:18 am »
hey nexus, it errored our bu glad it did.  i actually wanted to go the other way, rename the MEDIA to the description.

so, folder would have

dkong.zip
dkong.mp4 which would rename to “Donkey Kong (US set 1).mp4”

i am also trying out PinballX.  mame runs beautifully on it (and names are all correct as is) but pinball i am having issues with. sheesh!

nexusmtz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 489
  • Last login:June 01, 2022, 03:14:22 am
Re: i need to bulk rename media files ($20 bounty!)
« Reply #13 on: April 08, 2020, 02:17:18 am »
For the sake of completeness, excluding the zip is gci "$n.*" -ex "*.zip". I hope pinballx works out for you, since pinballY doesn't appear to be written with MAME in mind.

tony.silveira

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 697
  • Last login:February 17, 2024, 10:24:34 pm
    • my baby
Re: i need to bulk rename media files ($20 bounty!)
« Reply #14 on: April 08, 2020, 07:43:56 pm »
all right, i give up...

pinballX won’t launch VPX, everything else is great

pinballY has the mans naming issue, everything else is golden

so i just need to knuckle down and rename, game by game

sucks but at least it’s only once.