Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27202
    Display Error
    Participant

    Could someone please help me with a Find & Replace problem?
    I’m trying to batch update thousands of .SFZ files by inserting the current file folder name e.g.

    <region>
    sample=042_F2.wav
    pitch_keycenter=f2

    becomes:

    <region>
    sample=..\..\..\..\Audio\MULTISAMPLES\(!CurrentFilesFolderName!)\042_F2.wav
    pitch_keycenter=f2

    The relative part remains static but I need to dynamically insert the active file’s directory name somehow.
    Is it possible with ‘Find in Files’ & RegEx or should I be approaching this differently?

    Thank you for any help!

    #27203
    Display Error
    Participant

    Ahh, think I’m supposed to use macros… had a go at it but not really sure what I’m doing :/
    Gave up and used AutoHotkey with the Textfile & String Library

    #NoEnv
    #Persistent Force
    #SingleInstance Force
    #Include TF.ahk
    Loop, Files, E:\SAMPLES\TAL Sampler\Zampler RX\*.sfz, R	; recursively loop sfz files
    {
        file := A_LoopFileFullPath	; gets full directory
        SplitPath file,, dir				; splits out filename
        SplitPath dir, dir				; splits out last folder name
        F = !%A_LoopFileFullPath%	; enable file overwriting
        UpdatedRelativePath = sample=..\..\..\..\Audio\MULTISAMPLES\Zampler\%dir%\ 	; path with current folder
    
        TF_Replace(F,"sample=", UpdatedRelativePath)	; TF_Replace(Text, SearchText, Replacement="")
    }
    #27217
    Display Error
    Participant

    Ahh, think I’m supposed to use macros… had a go at it but not really sure what I’m doing :/
    Gave up and used AutoHotkey with the Textfile & String Library

    #NoEnv
    #Persistent Force
    #SingleInstance Force
    #Include TF.ahk
    Loop, Files, E:\SAMPLES\TAL Sampler\Zampler RX\*.sfz, R	; recursively loop sfz files
    {
        file := A_LoopFileFullPath	; gets full directory
        SplitPath file,, dir				; splits out filename
        SplitPath dir, dir				; splits out last folder name
        F = !%A_LoopFileFullPath%	; enable file overwriting
        UpdatedRelativePath = sample=..\..\..\..\Audio\MULTISAMPLES\Zampler\%dir%\ 	; path with current folder
    
        TF_Replace(F,"sample=", UpdatedRelativePath)	; TF_Replace(Text, SearchText, Replacement="")
    }
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.