Как создать скрипт, который копирует файлы из разных тематических папок?

Это внутренняя переменная, которая используется для пересылки всех аргументов, переданных скрипту, команде, которую вызывает скрипт, в этом случае qemu-system-x86_64.

1
задан 24 April 2018 в 15:28

3 ответа

Вот пример того, как цикл FOR может быть применен в сценарии bash для решения этой задачи:

#!/bin/bash

# Execute do-done inner part for each "item" under "folder/subjects/"
for subject in folder/subjects/*
do
    # Check whether the source file exists
    if [[ -f ${subject}/mri/norm.mgz ]]
    then
        # ${subject##*/} will cut the parent path from the value of the variable '$subject'
        echo "Processing: ${subject##*/}"

        # Create the new subject directory
        mkdir -p "folder/investigation_folder/fs_norms/${subject##*/}"

        # Copy the .mgz file into the new directory
        cp "${subject}/mri/norm.mgz" "folder/investigation_folder/fs_norms/${subject##*/}/"

        # Do the conversion to .nii (I'm not sure this is the correct syntax of mri_convert that you are using)
        mri_convert "folder/investigation_folder/fs_norms/${subject##*/}/norm.mgz" "folder/investigation_folder/fs_norms/${subject##*/}/norm.nii"
    fi
done
2
ответ дан 22 May 2018 в 11:16

Вот пример того, как цикл FOR может быть применен в сценарии bash для решения этой задачи:

#!/bin/bash # Execute do-done inner part for each "item" under "folder/subjects/" for subject in folder/subjects/* do # Check whether the source file exists if [[ -f ${subject}/mri/norm.mgz ]] then # ${subject##*/} will cut the parent path from the value of the variable '$subject' echo "Processing: ${subject##*/}" # Create the new subject directory mkdir -p "folder/investigation_folder/fs_norms/${subject##*/}" # Copy the .mgz file into the new directory cp "${subject}/mri/norm.mgz" "folder/investigation_folder/fs_norms/${subject##*/}/" # Do the conversion to .nii (I'm not sure this is the correct syntax of mri_convert that you are using) mri_convert "folder/investigation_folder/fs_norms/${subject##*/}/norm.mgz" "folder/investigation_folder/fs_norms/${subject##*/}/norm.nii" fi done
2
ответ дан 17 July 2018 в 16:15

Вот пример того, как цикл FOR может быть применен в сценарии bash для решения этой задачи:

#!/bin/bash # Execute do-done inner part for each "item" under "folder/subjects/" for subject in folder/subjects/* do # Check whether the source file exists if [[ -f ${subject}/mri/norm.mgz ]] then # ${subject##*/} will cut the parent path from the value of the variable '$subject' echo "Processing: ${subject##*/}" # Create the new subject directory mkdir -p "folder/investigation_folder/fs_norms/${subject##*/}" # Copy the .mgz file into the new directory cp "${subject}/mri/norm.mgz" "folder/investigation_folder/fs_norms/${subject##*/}/" # Do the conversion to .nii (I'm not sure this is the correct syntax of mri_convert that you are using) mri_convert "folder/investigation_folder/fs_norms/${subject##*/}/norm.mgz" "folder/investigation_folder/fs_norms/${subject##*/}/norm.nii" fi done
2
ответ дан 23 July 2018 в 17:09

Другие вопросы по тегам:

Похожие вопросы: