0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

`bash`によってフォルダに次々とアクセスし、ファイル名を変更[備忘録]

Posted at
#!/bin/bash

# 親フォルダを指定
parent_dir="A"  # 必要に応じて変更

# figure内のサブフォルダをループ
for subfolder in "$parent_dir"/*; do
  if [ -d "$subfolder" ]; then
    echo "Accessing folder: $subfolder"
    
    # サブフォルダ内の操作例
    # ファイルリストの表示
    ls "$subfolder"
    folder_name=$(basename "$subfolder")
    echo "$folder_name"
    mv "$subfolder/a.png" "$subfolder/a_$folder_name.png" 
  fi
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?