Page 1 of 1 1
Topic Options
#171699 - 2006-12-18 11:10 PM can't get IF EXIST with wildcard to work
booey Offline
Getting the hang of it

Registered: 2005-07-25
Posts: 76
Loc: USA
I am working on a script where part of it looks at a directory for any .csv files. If there are any .csv files, it creates a folder in another directory and copies the .csv file to that directory. So far, my script creates the directory whether or not a .csv file exists. Here's a snippet from the larger script.

Code:
Dim $ftpdir, $facility, $filename, $element, $RC, $datadir, $imported, $date
$datadir = "\\server\Data\OP\"
$date = @MONTHNO + "-" + @MDAYNO + "-" + @YEAR
$imported = "\\server\Data\imported\test\"
	If Exist ($datadir + "*.csv")
		MD $imported + $date
$importeddir = $imported + $date
		Move $datadir + "*.csv" $importeddir
		Else
	?	"Import doesn't exists"
EndIf


What is causing the IF EXIST to not work?

Also, what is the rule on wildcards when you concatenate variables and strings?

Thanks for the help.

Top
#171700 - 2006-12-18 11:20 PM Re: can't get IF EXIST with wildcard to work [Re: booey]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I've had mixed results doing the same thing you are trying. It seems sometimes it works and sometimes it doesn't, and I've never taken the time to figure out why... maybe we can now...

What is your kix version? Are you sure the path is correct? Have you tried mapping a drive and checking to see if works with a drive letter instead of the relative path?
_________________________
(... better days ahead)

Top
#171701 - 2006-12-18 11:29 PM Re: can't get IF EXIST with wildcard to work [Re: Allen]
booey Offline
Getting the hang of it

Registered: 2005-07-25
Posts: 76
Loc: USA
I am using Kix version 4.50.0.0. I am sure the patch is correct; I copied it from explorer.

I tried a mapped drive and that doesn't work either. I have actually typed out the relative path without a wildcard for the *.csv part and that didn't work either.

Top
#171702 - 2006-12-18 11:43 PM Re: can't get IF EXIST with wildcard to work [Re: booey]
booey Offline
Getting the hang of it

Registered: 2005-07-25
Posts: 76
Loc: USA
I just upgraded to the latest version of Kix and it seems to be working now.
Top
#171706 - 2006-12-18 11:52 PM Re: can't get IF EXIST with wildcard to work [Re: booey]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
You might consider downloading 4.53...

Try the following, changing the $files variable to a known file that does exist in the path. If that works, change it to *.csv and see if that works.

(untested)
Code:
$server="Server"
$share="Data"
$path="Imported\Test"
$files="filename.csv"

$imported="\\" + $server + "\" + $share + "\" + $path + "\" + files
? $imported
if exist($imported)
  ? "exists"
else
  ? "doesn't exist"
endif


{edit: Oh well... good glad the update fixed the problem... now I wonder if it was the same for me when I was having troubles }


Edited by Allen (2006-12-18 11:53 PM)
_________________________
(... better days ahead)

Top
#171708 - 2006-12-19 12:38 AM Re: can't get IF EXIST with wildcard to work [Re: booey]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I would not recommend doing MDY as that will become unsorted.

Using YYYYMMDD will always sort correctly.

My recommendation for a code change would be something like this.

PHP:
Break On Dim $Archive $Archive = Trim(Join(Split(@DATE,'/'),'-'))+'_'+Trim(Join(Split(@TIME,':'),'')) 'Archive Date for var is: ' + $Archive ?


Which produces the following including the time as an example.

Archive Date for var is: 2006-12-18_153635

Which translates to December 12, 2006 at 3:36 PM and 35 seconds

.

Top
#171732 - 2006-12-19 04:13 PM Re: can't get IF EXIST with wildcard to work [Re: NTDOC]
booey Offline
Getting the hang of it

Registered: 2005-07-25
Posts: 76
Loc: USA
I followed your recommendation NTDOC. That should work good. However, is it possible to do something like "@date -1" to get the previous days date as the folder name?

Thanks.

Top
#171734 - 2006-12-19 05:03 PM Re: can't get IF EXIST with wildcard to work [Re: booey]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
you should consider using one of the DateCalc/Datemath udfs for that task as @mdayno-1 won't work if it is the 1st of anything
_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.132 seconds in which 0.1 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org