Skip to content

Instantly share code, notes, and snippets.

@yuki-inaho
Created June 13, 2023 06:03
Show Gist options
  • Select an option

  • Save yuki-inaho/76a7e9c9900630b44fdd40bae1b39796 to your computer and use it in GitHub Desktop.

Select an option

Save yuki-inaho/76a7e9c9900630b44fdd40bae1b39796 to your computer and use it in GitHub Desktop.
The shell script to extract images whose name is written in whitelist.txt
#!/bin/bash
# ファイルパス
whitelist_file="whitelist.txt"
raw_dir="input"
extracted_dir="extracted"
# extractedディレクトリが存在しない場合は作成する
if [ ! -d "$extracted_dir" ]; then
mkdir "$extracted_dir"
fi
# whitelist.txtから画像名を読み取り、該当する画像をコピーする
while IFS= read -r image_name || [[ -n "$image_name" ]]; do
image_path="$raw_dir/$image_name"
if [ -f "$image_path" ]; then
cp "$image_path" "$extracted_dir"
echo "Copied $image_name"
else
echo "Image not found: $image_name"
fi
done < "$whitelist_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment