Autocomplete content in a text document with cmd.exe

0

I have the following temp.txt with these contents:

01. título a.flac  
02. título b.flac  
03. título c.flac  

I convert to the following metaflac.txt template:

metaflac --set-tag=TITLE="" --set-tag=TRACKNUMBER= "01. título a.flac"  
metaflac --set-tag=TITLE="" --set-tag=TRACKNUMBER= "02. título b.flac"  
metaflac --set-tag=TITLE="" --set-tag=TRACKNUMBER= "03. título c.flac"

with this command in a bat:

FOR /F "tokens=* delims= " %%G IN (temp.txt) DO ECHO metaflac --set-tag=TITLE="" --set-tag=TRACKNUMBER= "%%G">> "Plantilla metaflac.txt"

From there I would like to autocomplete the TRACKNUMBER field (eg TRACKNUMBER = 1 to TRACKNUMBER = 99)
and the field TITLE (TITLE="title a" to TITLE="title z")

Thanks in advance for the help.

    
asked by user84131 22.05.2018 в 14:27
source

1 answer

0

With the for you have used, you almost have the solution. The only thing you need to change is the% share tokens and% share%. In delims you must indicate which character serves as delimiter, in your case the ".", In delims you say, with the previous partition, what pieces (tokens) you want to use.

With the delimiter "." your lines are split in

  • Token 1: 01
  • Token 2: title a
  • Token 3: flac

With the for adapted like this:

SETLOCAL EnableDelayedExpansion

FOR /F "tokens=1,2,3 delims=." %%g IN (temp.txt) DO (
    set title=%%h
    set title=!title:~1!
    set /a track=10000%%g %% 10000
    ECHO metaflac --set-tag=TITLE="!title!" --set-tag=TRACKNUMBER="!track!">> "Plantilla metaflac.txt"
)

The strong generates a variable for each token, the first being tokens , and the following ones in alphabetical order. with this I think you can compose your file better.

Result:

metaflac --set-tag=TITLE="título a" --set-tag=TRACKNUMBER="1"
metaflac --set-tag=TITLE="título b" --set-tag=TRACKNUMBER="2"
metaflac --set-tag=TITLE="título c" --set-tag=TRACKNUMBER="3"
    
answered by 25.05.2018 в 11:02