From d5b13c41eabd0f1b190cd0d11dcd0fb5f162fc68 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 21 Apr 2023 20:22:56 +0000 Subject: [PATCH] Added check for date directory before creating it in AST_VDsales_export.pl script git-svn-id: svn://192.168.202.10@3714 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_VDsales_export.pl | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/bin/AST_VDsales_export.pl b/bin/AST_VDsales_export.pl index 8ee3b1cc..743f2352 100644 --- a/bin/AST_VDsales_export.pl +++ b/bin/AST_VDsales_export.pl @@ -36,6 +36,7 @@ # 160722-1140 - Added --nodatedir option # 220307-0915 - Added 'tab-CSScustomUSA' format # 230115-1523 - Added --filedate-calldate option +# 230421-1614 - Added check for date directory before creating it # $txt = '.txt'; @@ -959,12 +960,34 @@ if ($ftp_audio_transfer > 0) { if ($YEARDIR > 0) { - $ftp->mkdir("$year"); - $ftp->cwd("$year"); - } - $ftp->mkdir("$start_date"); - $ftp->cwd("$start_date"); - } + @file_list = $ftp->ls(); + if ( grep( /^$year$/, @file_list ) ) + { + # year directory exists do just enter it + $ftp->cwd("$year"); + } + else + { + # year directory does not exist + # make it and enter it + $ftp->mkdir("$year"); + $ftp->cwd("$year"); + } + } + @file_list = $ftp->ls(); + if ( grep( /^$start_date$/, @file_list ) ) + { + # start_date directory exists do just enter it + $ftp->cwd("$start_date"); + } + else + { + # start_date directory does not exists + # make it and enter it + $ftp->mkdir("$start_date"); + $ftp->cwd("$start_date"); + } + } $start_date_PATH = "$start_date/"; $ftp->binary(); $ftp->put("$tempdir/$FILES[$i]", "$FILES[$i]");