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:
    675
    Likes Received:
    453
    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:
    36
    Likes Received:
    21
    Location:
    Istanbul
  4. fiction

    fiction Audiosexual

    Joined:
    Jun 21, 2011
    Messages:
    1,921
    Likes Received:
    702
    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.
     
  6. dim_triad

    dim_triad Producer

    Joined:
    Mar 17, 2014
    Messages:
    533
    Likes Received:
    116
    doesn't batchmod (the app) handle this?

    It seems like it would... but man, Im just learning. Take care everyone, have a great night!
     
  7. xorome

    xorome Audiosexual

    Joined:
    Sep 28, 2021
    Messages:
    1,187
    Likes Received:
    866
    If you need to run something on a larger number of files, using 'find' on Mac OS, BSD and Linux is the easiest option. If you're on Windows, or if you want a 'find' alternative that can execute tasks in parallel, or an alternative that works on all platforms, grab sharkdp's 'fd'. fd's syntax is inspired by 'find' and has some advanced features.
     
Loading...
Similar Threads - Batch modify files Forum Date
Batch Re-Save Kontakt Nov 16, 2024
MIDI to Audio Batch Converter (Mac) Working with Sound Nov 11, 2024
How to batch resave a Kontakt Library with a Smart Voicing GUI Kontakt Oct 27, 2024
Batch convert Wav files to (or close to) zero size when minifying Kontakt Libraries? Kontakt Jul 17, 2024
Batch audio processor for Mac? (sample rate, bit depth, etc.) Software Jun 13, 2024
Loading...