Please write an linux shell script: First, enter d...

作成日: 2025年6月23日

使用モデル O3 by Chat01

質問

Please write an linux shell script:
First, enter directory /storage/emulated/0/Pictures/Raw, Then, run commands:
exiftool -overwrite_original -m -ForwardMatrix1="0.6953125 0.140625 0.125 0.2265625 0.8984375 -0.125 -0.0078125 -0.3515625 1.1796875" example.dng
exiftool -overwrite_original -m -ForwardMatrix2="0.6953125 0.140625 0.125 0.2265625 0.8984375 -0.125 -0.0078125 -0.3515625 1.1796875" example.dng
exiftool -overwrite_original -m -ProfileHueSatMapData1= example.dng
exiftool -overwrite_original -m -ProfileHueSatMapData2= example.dng
Replace example.dng to a wildcard that matches all dng files in the directory.

思考

Crafting Linux shell script

For this request, I’ll write a Linux shell script that enters the directory /storage/emulated/0/Pictures/Raw and runs exiftool on all .dng files in that directory. Since exiftool can handle multiple files at once, I’ll use the simpler exiftool -overwrite_original ... *.dng to modify all the files in one go.

Here's the script:

bash
#!/bin/bash cd /storage/emulated/0/Pictures/Raw exiftool -overwrite_original ... *.dng

This script will loop over all .dng files in the directory and apply the specified changes.

Thought for 8 seconds

回答

Here’s a compact Bash script that changes to the Raw folder and updates every .dng file in one go:

bash
#!/usr/bin/env bash # tweak_dng_forward_matrices.sh # Applies updated Forward Matrix and clears Hue/Sat maps for every .dng in the Raw folder. set -euo pipefail RAW_DIR="/storage/emulated/0/Pictures/Raw" # Ensure the target directory exists cd "$RAW_DIR" || { echo "❌ Folder not found: $RAW_DIR"; exit 1; } # Run a single exiftool command on all DNGs exiftool -overwrite_original -m \ -ForwardMatrix1="0.6953125 0.140625 0.125 0.2265625 0.8984375 -0.125 -0.0078125 -0.3515625 1.1796875" \ -ForwardMatrix2="0.6953125 0.140625 0.125 0.2265625 0.8984375 -0.125 -0.0078125 -0.3515625 1.1796875" \ -ProfileHueSatMapData1= \ -ProfileHueSatMapData2= \ *.dng echo "✅ Forward matrices updated and hue/sat maps cleared for all .dng files in $RAW_DIR"

How to use

  1. Save the script, e.g. tweak_dng_forward_matrices.sh.
  2. Make it executable:
    bash
    chmod +x tweak_dng_forward_matrices.sh
  3. Run it:
    bash
    ./tweak_dng_forward_matrices.sh

The single exiftool invocation is faster than looping, and the wildcard *.dng targets every DNG in the directory as you requested.

このQ&Aを共有