Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Bulk Renaming the "FILE" line of a cue sheet (Read 4563 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Bulk Renaming the "FILE" line of a cue sheet

Hello,

This is my first post, and I've tried searching but was surprised to find that this hasn't been asked (so far as I can tell).

I'm trying to find a way to bulk rename the FILE line of about 400 cue sheets to the name of the file..

E.g.

Filename 123.cue has

FILE "Somerandomfile.mp3" MP3

listed on the 4th line when opened with word pad. I would like to have it read

FILE "123.mp3" MP3

if possible... so I can batch split the corresponding MP3's that are named with the same naming convention.

Would anyone be able to assist or point me in the right direction?

Any help would be sincerely appreciated!!

Bulk Renaming the "FILE" line of a cue sheet

Reply #1
Some tools are probably easy to find with Google, but if you want straight solution it would inevitably involve using regex. PowerGrep comes to my mind, but that's not free solution, then maybe "Find in files" option in some editors provide find/replace and regex option, but I use just SciTE and it can do what you want but only in opened buffers (files opened in editor)

OTOH, such CLI tool inside Windows shell does not exist, although some batch acrobatics can make it work. However here is easy way by using SED.EXE (you can find it as part of UnxUtils or GnuWin32 tools for Windows). I'll go easy as I don't know your skills, and assume you are running Windows and all CUE sheets refer to MP3 reference files:

1. copy SED.EXE and all your CUE sheets in one folder
2. make backup of your CUE sheets
3. open command prompt in that folder
4. paste this at command prompt:

Code: [Select]
for %i in (*.cue) do sed -i -r 's/FILE ".*?"/FILE "%~ni.MP3"/' "%i"

which will replace single line matches of "FILE *" and replace it with the name of current CUE sheet + MP3 extension

note that CUE sheets file names must not contain "&" (Ampersand character)

Bulk Renaming the "FILE" line of a cue sheet

Reply #2
Well, you seem quite well versed on the subject! I am impressed!! however I seem to be getting an error (probably human error)

I just put sed.exe into a test folder like you described  (with 3x .cue and 3x .mp3 files). I then went into command prompt and went to the directory and typed the following:

J:\Library\Media\Unsorted Media\complete\Music\TEST>sed.exe for %i in (*.cue) do sed -i -r 's/FILE ".*?"/FILE "%~ni.MP3"/' "%i"

I also tried (without "for")

J:\Library\Media\Unsorted Media\complete\Music\TEST>sed.exe  %i in (*.cue) do sed -i -r 's/FILE ".*?"/FILE "%~ni.MP3"/' "%i"

I am getting the following:

sed.exe: invalid option -- i
Usage: sed.exe [OPTION]... {script-only-if-no-other-script} [input-file]..

  -n, --quiet, --silent
                suppress automatic printing of pattern space
  -e script, --expression=script
                add the script to the commands to be executed
  -f script-file, --file=script-file
                add the contents of script-file to the commands to be exe
      --help    display this help and exit
  --text    switch to text mode
  -V, --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

E-mail bug reports to: bug-gnu-utils@gnu.org .
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

any idea why I might be getting this?

Thanks again for your assistance!

 

Bulk Renaming the "FILE" line of a cue sheet

Reply #3
Find and replace operations in a text file really belong in off-topic, so don't be surprised when this thread gets moved.

Bulk Renaming the "FILE" line of a cue sheet

Reply #4
Find and replace operations in a text file really belong in off-topic, so don't be surprised when this thread gets moved.


thanks for the heads up, I would move it myself...