IPB

Welcome Guest ( Log In | Register )

> Hydrogenaudio Forum Rules

- No Warez. This includes warez links, cracks and/or requests for help in getting illegal software or copyrighted music tracks!
- No Spamming or Trolling on the boards, this includes useless posts, trying to only increase post count or trying to deliberately create a flame war.
- No Hateful or Disrespectful posts. This includes: bashing, name-calling or insults directed at a board member.
- Click here for complete Hydrogenaudio Terms of Service

 
Reply to this topicStart new topic
Bulk Renaming the "FILE" line of a cue sheet
ar4s
post Jan 2 2011, 20:37
Post #1





Group: Members
Posts: 3
Joined: 2-January 11
Member No.: 86994



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!!
Go to the top of the page
+Quote Post
romor
post Jan 3 2011, 01:42
Post #2





Group: Members
Posts: 682
Joined: 16-January 09
Member No.: 65630



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
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)


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
ar4s
post Jan 3 2011, 05:38
Post #3





Group: Members
Posts: 3
Joined: 2-January 11
Member No.: 86994



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!

This post has been edited by db1989: Sep 2 2011, 00:06
Reason for edit: removing pointless quote of above post
Go to the top of the page
+Quote Post
greynol
post Jan 3 2011, 05:44
Post #4





Group: Super Moderator
Posts: 10345
Joined: 1-April 04
From: San Francisco
Member No.: 13167



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

This post has been edited by greynol: Jan 3 2011, 05:45


--------------------
Breath is found in plots and DR figures.
Go to the top of the page
+Quote Post
ar4s
post Jan 3 2011, 08:37
Post #5





Group: Members
Posts: 3
Joined: 2-January 11
Member No.: 86994



QUOTE (greynol @ Jan 3 2011, 13:44) *
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...
Go to the top of the page
+Quote Post
greynol
post Jan 3 2011, 08:39
Post #6





Group: Super Moderator
Posts: 10345
Joined: 1-April 04
From: San Francisco
Member No.: 13167



You're welcome.


--------------------
Breath is found in plots and DR figures.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 28th December 2014 - 10:36