因此,我将下面的bash脚本放在一起,并希望修改我获取的文件路径目录。
我的布局是这样的
/home/videos_test/categoryname/1/vid.mp4
/home/videos_test/categoryname/2/randomvid.mp4
我想修改它抓取的文件路径,使其看起来像这样
/home/videos_test/changed_folder/1/vid.mp4
/home/videos_test/changed_folder/2/randomvid.mp4
完整脚本
#!/bin/bash
echo "Type the category that you want, followed by [ENTER]:"
read category
export FILE_PATH="/home/videos_test"
export STAR="/*"
FILE_PATH=$FILE_PATH"/"$category;
echo $FILE_PATH;
minimumsize=1000
for dir in $FILE_PATH$STAR$STAR; do
[[ ! -f "${dir}" ]] && continue # if its NOT a file then skip
actualsize=$(du -k "$dir" | cut -f 1)
if [[ ! $actualsize -ge $minimumsize ]]; then #if file is less than 1mb delete it
echo $dir
echo size is under $minimumsize kilobytes
rm "$dir"
echo deleted
else #for files over 1mb in size convert with ffmpeg
full_file=$(basename $dir)
full_dir=$(dirname $dir)
echo $full_file
echo $full_dir
ffmpeg -i "$dir"
#ffmpeg output file directory needs to be mirrored but with a folder change
read -p "Press any key to resume ..."
fi
done
我的文件夹输出为ffmpeg我想
/home/videos_test/$category _new/1/vid.mp4
/home/videos_test/$category _new/2/randomvid.mp4
2条答案
按热度按时间svmlkihl1#
假设条件:
read category
${category}_new
替换${category}
(在目录名中_new
后缀一种方法是使用参数替换创建新的目标目录名,然后使用
mkdir -p
创建新目录:dddzy1tm2#