#!/bin/bash
SRC_DIR="/home/liudanny/scripts" # put your source directory
DST_DIR="/home/liudanny/Downloads" # put your destination directory
for src_full_name in "$SRC_DIR"/* # loop all the files in source directory
do
fname=$(echo ${src_full_name}|sed 's#^.*/##') # get the file name
echo "name:$fname"
dst_full_name=`printf "%s/%s" $DST_DIR $fname` # generate the destination file name
echo "dst_full_name:$dst_full_name"
if [ -e $dst_full_name ]; # check if destination file exists
then
echo "File: $fname exists..."
else
echo "Do copying $fname ..."
cp $src_full_name $dst_full_name # if not exists, then copy file
fi
done
No comments:
Post a Comment