我正在将我的视频库从H.264转换为H.265,以节省空间。然而,我所有的文件都在一个我想要保留的文件结构中。我使用Adobe Media Encoder对所有文件进行编码,但它不能保留文件夹结构-仅将H.265文件输出到单个文件夹中。
之后如何在文件夹结构中批量搜索确切的文件名(xxx.mp4),然后将其替换为单个文件夹中的新H.265文件(也称为xxx.mp4)?
我有1000+视频,所以手动不起作用:-)
有什么终端命令可以帮上忙吗?
发布于 2017-12-17 06:03:55
我非常不愿意在你的Mac上对成千上万的视频进行大规模的修改,所以我已经在这里完成了99%的修改。请在执行任何其他操作之前进行备份。
好,警告完毕。在您的主目录中将以下文件另存为go
#!/bin/bash
# Change this to match the top-level of where all your videos are stored
VIDEOLIB="$HOME/path/to/my/videos"
shopt -s nullglob nocaseglob
# Loop through all mp4 files in the current dorectory
for video in *mp4; do
# Get this file's inode number (unique id)
inode=$(stat -f "%i" "$video")
# Now find a friend with same name but different inode number
friend=$(find "$VIDEOLIB" -name "$video" \! -inum $inode)
if [ -z "$friend" ] ; then
echo "ERROR: $video has no friend"
else
echo "$video is friends with:"
echo " $friend"
fi
done然后启动终端,并使上述脚本可执行-只需执行一次:
chmod +x $HOME/go现在将目录更改为媒体编码器存储其输出文件的位置,例如:
cd "path/to/Adobe Media Encoded files"并使用以下命令运行脚本:
$HOME/go它应该运行所有的h265编码的视频,并找到每个匹配的文件。它实际上不做任何事情,除了告诉你匹配,你需要像这样的一行
mv "$video" "$friend"从最后一行算起大约3行,上面有fi...但是先进行备份,然后再看看是否一切正常。
发布于 2021-10-19 18:13:12
我知道它很旧,但也许有人需要它,下面是我是如何做到的:
创建一个file.sh并将其放入:
find /path/to/file/folder_01 -name '*.mp4' | while read f; do
f2=$(find /path/to/folder/folder_02 -name "${f##*/}")
[[ $f2 ]] && cp "$f" "$f2"
done然后使用终端运行:
cd file/location
bash file.shhttps://stackoverflow.com/questions/47836872
复制相似问题