>我有一堆视频文件,我想将它们放入与视频文件同名减去扩展名(.mov)的目录中
例如,给定以下目录,我将如何编写脚本为每个与文件同名(减去.mov)的.mov文件创建一个目录,然后将.mov文件放入该目录中?
/Volumes/06a_SD_Video_01/_COLLECTIONS/TR2014_295_Walter_Reed/DER_01/
├── TR2014_295_10_1a_PM.mov
├── TR2014_295_11_1a_DER_01.mov
├── TR2014_295_12_1a_DER_01.mov
├── TR2014_295_13_1a_DER_01.mov
├── TR2014_295_14_1a_PM.mov
├── TR2014_295_15_1a_DER_01.mov
├── TR2014_295_16_1a_DER_01.mov
├── TR2014_295_17_1a_DER_01.mov
├── TR2014_295_18_1a_DER_01.mov
├── TR2014_295_19_1a_DER_01.mov
├── TR2014_295_19_1b_DER_01.mov
├── TR2014_295_1_1a_PM.mov
├── TR2014_295_20_1a_DER_01.mov
├── TR2014_295_21_1a_PM.mov
├── TR2014_295_22_1a_DER_01.mov
├── TR2014_295_22_1b_DER_01.mov
├── TR2014_295_23_1a_DER_01.mov
├── TR2014_295_2_1a_PM.mov
├── TR2014_295_3_1a_DER_01.mov
├── TR2014_295_4_1a_DER_01.mov
├── TR2014_295_5_1a_DER_01.mov
├── TR2014_295_6_1a_DER_01.mov
├── TR2014_295_7_1a_DER_01.mov
├── TR2014_295_8_1a_DER_01.mov
├── TR2014_295_9_1a_DER_01.mov
这里有一种方法:
脚本:
cd "$1"
for m in *.mov; do
d=`echo "$m" | sed 's/.mov$//'`
mkdir "$d"
mv "$m" "$d"
done
用法:
sh <scriptname.sh> "<directory>"
例如,
sh mov2dir.sh "/Volumes/06a_SD_Video_01/_COLLECTIONS/TR2014_295_Walter_Reed/DER_01/"