Hello,
I made a script to copy files from one directory to another and move file after the copy is done. When files are present in the source directory there is no problem but when no file are present I'm getting an error.
Please help !!
date >> $log_txt
list=`ls "$source_txt"$extenstion_txt 2> /dev/null`
old_ifs=${IFS};IFS=$' '
echo $list | echo `wc -l` "files to copy." >> $log_txt
echo $list | while read file; do
echo $file >> $log_txt
cp -f "$file" $destination_txt
mv -f "$file" $archives_txt
done
IFS=${old_ifs}
date >> $log_txt
_________
log when files are copied
Sun Dec 14 12:39:52 EST 2008
2 files to copy.
/Users/lsimoneau/Desktop/test/pc/textes/fichier01 - copie 01 09-03-47.txt
/Users/lsimoneau/Desktop/test/pc/textes/fichier01 - copie 01 09-04-59.txt
Sun Dec 14 12:39:52 EST 2008
_________
log when files are not present
Sun Dec 14 12:40:04 EST 2008
1 files to copy.
Sun Dec 14 12:40:04 EST 2008
cp: fts_open: No such file or directory
mv: rename to /Users/lsimoneau/Desktop/test/z_archives_txt/: No such file or directory