Я пытаюсь написать сценарий для перемещения файлов после их использования в bash. Я использую "открыть с" мой сценарий, так $1
является файл (FULLPATH)bash - Как определить, находится ли мой файл в (под) папке
#! /bin/bash
fullpath="$1"
rootpath="/home/guillaume/Videos"
foo=${fullpath#${rootpath}}
echo "$foo"
zenity --question --title="Déplacer le fichier ?" --text="Déplacer le fichier vers le dossier VU ?"
if [ $? = 0 ]
then
if # foo don't have a folder
then
mv $rootpath"$foo" /home/guillaume/Videos/VU
elif # foo contains a folder
# command to copy the subdirectory
fi
fi
Результат для foo
может быть:
/title_subdirectory/file with_spaces or_not.ext
или
/file with_spaces or_not.ext
Как определить, находится ли файл в подкаталоге, а затем переместить весь подкаталог и файлы?
Спасибо за помощь. Я использую 'base = $ (basename" $ foo ")' и 'complete =" $ {foo # /} "', тогда я сравниваю оба укуса. – Guillaume