Batch editing cue files

Microsoft Windows xp professional w/serv...
July 1, 2010 at 08:57:43
Specs: Windows XP

I wish to edit about 1000 cue files. I'd like to run a script that modifies the FILE "SOME_FILE.bin" BINARY line to change it to the dir's name containing it and add a .bin. For example, I have a cue file like this one in dir SOME_DIR:

TRACK 01 MODE2/2352
INDEX 01 00:00:00

and I'd like to change it to:

TRACK 01 MODE2/2352
INDEX 01 00:00:00

File names in cues are random lenght, so are dir names. Each CUE is in its own dir.

Any help is much appreciated.

See More: Batch editing cue files

Report •

July 17, 2010 at 16:20:37
Each file is just those 3 lines? You just want to change part of the first line of each? Is there a consistent pattern to what string you want to match and what to replace it with?

One possibility would be to use a batch file to loop through all the cue files. Feed each one to the sed utility (built into Linux, but you can download and install a version for Windows). The sed does a search-and-replace and writes out a new file. Copy the temp new file back to the old file and go on to the next cue file. You could have multiple 'sed' calls for multiple patterns. You might get a hold of 'grep' to check if the pattern is found in a specific file and only run that one 'sed' against the file, saving you unncessarily running 'sed' hundreds of times per cue file. It all depends on what the search and replacement patterns look like.

That's probably easier than writing a Perl script to do the job, unless the search pattern and replacement are not simple (say, you have hundreds of names to search for and replace with unique strings).

Report •
Related Solutions

Ask Question