I looking for a long file names to short converter

Page 2/3
1 | | 3

By ericb59

Paladin (870)

ericb59's picture

23-02-2019, 11:51

@GDX Why do you want to reinvent the wheel ?
http://msx.ebsoft.fr/roms/index.php?v=%25&Send=Send

I have a mySQL Database, it can be updated with new roms ...

By gdx

Prophet (3043)

gdx's picture

23-02-2019, 15:49

I do not know where is your database and now it would take me longer to adapt your list and add what's missing than continue mine.

I am looking for something simple, fast and offline. Something that works for one or many files in a directory (and if possible with the taking into account of subdirectories).

@Pensionner: I left the name extensions in the database in case it comes useful. Tell me if it's better to remove them now.

By Pencioner

Paladin (955)

Pencioner's picture

23-02-2019, 16:25

@gdx - it is traversing subdirs now. i have a question - the hashes in your db is MD5 ? extensions doesn't matter, while it is the same over all file, btw, but i'm gonna change it to YAML format, as very convenient both for parsing from programming language and very readable and manually editable by human too
example of YAML file - your database converted to it. let me know if the hashes are not MD5 (i'm gonna include support for other hashing if needed, btw)

EDIT: your file has a missing short name for file Professional Mahjong Gokuu (J).rom and it screwed up the rest of file's convertion to YAML :) one of reasons while formats which are kind of positional (one record is three lines in your case) are not error prone. I have put the name PROMAHJG.ROM for it (give another one if this is bad btw)

By TomH

Champion (327)

TomH's picture

23-02-2019, 16:21

I'm going to make one more appeal for sanity, a slightly different one: if there's any desire to make this "for the community", please don't try to retain metadata within filenames. Put the separate fields into the YAML, and compose the not-for-humans file "name" only if desired. That would both make life a lot easier for those of us who don't want out fuming system uglified, and for a plethora of tools that might want the metadata.

By Pencioner

Paladin (955)

Pencioner's picture

23-02-2019, 16:27

@TomH i agree, i think i'm gonna later refine long names and add 'language: Japanese' for one having (J) in name, when i'm ready with main functionality

By Meits

Scribe (5545)

Meits's picture

23-02-2019, 16:55

This tool might be very handy in creating a database. It can extract several hashes from files. Just drag and drop complete directories and export the desired columns, which would be filename+sha1.

By Manuel

Ascended (15763)

Manuel's picture

23-02-2019, 17:45

Meits: but Python can do that in a few lines as well.. no need for a separate tool.

By Meits

Scribe (5545)

Meits's picture

23-02-2019, 18:01

I don't know how gdx has worked until now and if he has a python script in his possession.

By Pencioner

Paladin (955)

Pencioner's picture

23-02-2019, 23:50

Initial implementation can be found here
You will need the YAML i converted from the initial file provided by @gdx
I have added support for crc32, md5 and sha1 so database can contain any of the hashes (you can have different hashes in the same db, if you want)
@gdx: please don't remove the '.ROM' file extension from names - i think the same tool can be useful for renaming other media like diskimages too, no reason to limit it to ROMs btw, and currently there are some entries without an extension - please fix when you have a time

The usage:

$ ./hash_file_renamer.py --help
usage: hash_file_renamer.py [-h] [-l] [-o] [-d DATABASE] dirs [dirs ...]

Rename files based on hash.

positional arguments:
  dirs                  directories to look for files

optional arguments:
  -h, --help            show this help message and exit
  -l, --long-names      use long name for renaming
  -o, --overwrite       overwrite file on rename if exists
  -d DATABASE, --database DATABASE
                        database file name

any suggestions for improvement welcome (i would like f.e. to add the --interactive option to ask user from console in case the file already exists and no --overwrite is given, so user can decide what to do, i'll do this improvement later when i have time)

By gdx

Prophet (3043)

gdx's picture

24-02-2019, 01:45

OK for YAML.

Pencioner wrote:

the hashes in your db is MD5 ?

No, sha1 as all MSX database. I think other checksums are not necessary. This complicates the database for nothing.

Pencioner wrote:

please don't remove the '.ROM' file extension from names - i think the same tool can be useful for renaming other media like diskimages too

That's why I left them.

About options, I think only one is useful: "-l" to renames with long names instead of short names by default.

I can not wait to see the result. Thank you.

Page 2/3
1 | | 3