Batch modify files in terminal

Discussion in 'Mac / Hackintosh' started by curtified, Nov 2, 2021.

  1. curtified

    curtified Rock Star

    Joined:
    Feb 3, 2015
    Messages:
    627
    Likes Received:
    426
    I'm trying to find a way to batch apply terminal commands to a selection of plugins at once in terminal.

    I usually use these commands:
    sudo codesign -f -s -
    sudo codesign -fs -
    sudo chmod u+x
    Sudo xattr -cr
    sudo xattr -r -d com.apple.quarantine
    sudo chmod +x

    Is there a way I can have it run through all of those commands on multiple files at once in terminal? Or is there an app that I can do that with?
     
  2.  
  3. Havakak

    Havakak Ultrasonic

    Joined:
    May 7, 2020
    Messages:
    35
    Likes Received:
    21
    Location:
    Istanbul
  4. fiction

    fiction Audiosexual

    Joined:
    Jun 21, 2011
    Messages:
    1,893
    Likes Received:
    688
    In bash:

    for f in file1 file2 file3 file4 file5
    do
    sudo codesign -f -s - "$f"
    sudo codesign -fs - "$f"
    sudo chmod u+x "$f"
    sudo xattr -cr "$f"
    sudo xattr -r -d com.apple.quarantine "$f"
    sudo chmod +x "$f"
    done

    Before running that, you might want to edit your sudo permissions to avoid entering your root password by allowing codesign, chmod, xattr to run as sudo root from your user account (not recommended from the security perspective so better remove them when you're done):
    sudo visudo
     
    Last edited: Nov 20, 2021
  5. phumb-reh

    phumb-reh Guest

    The best way IMO is to run the script as root (using sudo) and then leave the sudos out of the script, so basically something like this:

    Code:
    #!/usr/bin/env bash
    
    for f in file1 file2 file3 file4 file5
    do
        codesign -f -s - "$f"
        codesign -fs - "$f"
        chmod u+x "$f"
        xattr -cr "$f"
       xattr -r -d com.apple.quarantine "$f"
       chmod +x "$f"
    done
    
    Save this to a convenient location, say ~/scripts/signplugs.sh (~ means home directory)

    Then make it executable with

    Code:
    chmod +x ~/scripts/signplugs.sh
    
    Then run it using sudo

    Code:
    sudo ~/scripts/signplugs.sh
    

    You might want to add arguments for file1, file2... and so on, and perhaps add it to your PATH. Feel free to ask if you need help.
     
Loading...
Similar Threads - Batch modify files Forum Date
Software to Batch Remove Silence . . . Working with Sound Mar 9, 2024
Kontakt 6 Portable: Batch-resave speed improvement doesn’t last Kontakt Feb 11, 2024
Can’t find batch re-save on latest Kontakt from sister site? Kontakt Nov 30, 2023
Batch .wav conversion for omnisphere Omnisphere Oct 2, 2023
MIDI to MP3 (or WAV) Batch Converter? Working with Sound Aug 16, 2023
Loading...