解密:
find -name "*" -type l -exec bash cpfile.sh '{}' '../outfiles' \;
拷贝链接文件:
find -name "*" -type l -exec bash cplink.sh '{}' '../outfiles' \;
重命名:
find -name "*.outx.iso" -type l -exec bash mvfile.sh '{}' '.outx.iso' \;
cpfile.sh
#!/bin/bash
path1=`echo ${1:2}`
# ##if dir not exist create it;
if [ ! -d $2 ];then
mkdir -p "$2"
fi
path2="$2"/"$path1"
# echo $alldir
alldir=`dirname "$path2"`
# echo "$alldir"
if [ ! -d $alldir ];then
mkdir -p "$alldir"
fi
##cp link to new dir
cat "$1" > "$path2"".outx.iso"
# echo "end"
cplink.sh
#!/bin/bash
path1=`echo ${1:2}`
# echo $path1
path2="$2"/"$path1"
# echo $alldir
alldir=`dirname "$path2"`
# echo "$alldir"
if [ ! -d $alldir ];then
mkdir -p "$alldir"
fi
##cp link to new dir
cp -d "$1" "$path2"
# echo "end"
mvfile.sh
cat mvfile.sh
#!/bin/bash
##filname: mvfile.sh ---
path1=`echo ${1:2}`
# echo $alldir
rename=${path1%"$2"}
#echo "$rename"
##rename path1 to $rename
mv "$path1" "$rename"
# echo "end"
本文介绍了一系列Shell脚本,用于实现文件的查找、拷贝、重命名等批量操作,并详细展示了如何通过自定义脚本来自动化这些任务。适用于需要处理大量文件的场景。
2万+

被折叠的 条评论
为什么被折叠?



