SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
FTPFileSize and directories

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
FTPFileSize and directories
Author Message
~Joe



Joined: 18 Dec 2003
Posts: 42

Post FTPFileSize and directories Reply with quote

hey,

Using the FTPdir command how can I disseminate between files and directories with the returned results?

I get a file list: file1,file2,file3,file4.
File1 = dir
File2 = dir
File3 = file
File4 = file
I am performing a ftpdir command that returns “file1,file2,file3,file4”

When I process file1 with FTPfileSize it is returning the a value even though it is a directory. I expected zero bytes back

I want to process files meeting a file mask and discard the directories. Any suggestions??

CODE sample:

Dim res_output_path_and_name, string, "" //the returned file path and name of file Resolute will process.
dim res_filemask, string, "fi*.*", //file mask to retreive from EPIC server.
dim res_directory, string, "/dir1/dir2/claim/" //Directory to look in.
dim res_path_mask, string, ""
dim res_d_results, string, "" //Comma seperated list of files returned from the FTPDir command.

//This is the list of files to be processed.
dim res_res_lngth, number, "" //the length of the results file.
dim m_lngth, number, "" // used to determin if a Claims files are in the
dim m_var_name, string, "" // this is the variable returned from res_d_results.

dim m_file_exists, boolean, "" //set to true if the name found is a file and not a directory.

// /epic/resolute/claim directory

ftpdir res_ftpserver, res_ftpuser, res_ftppassword, res_directory, res_d_results
messagebox res_d_results
length res_d_results, res_res_lngth

LoopWhile res_res_lngth, e_loop

top_of_Loop:

length res_d_results, res_res_lngth

instr res_d_results, ",", 1, m_lngth

//this retreives the first file/directory

left res_d_results, m_lngth, m_var_name

subtract res_res_lngth, m_lngth, res_res_lngth

right res_d_results, res_res_lngth, res_d_results

instr m_var_name, ",", 1, m_lngth

ifthen (m_lngth, chomp)

goto check_file

chomp:

subtract m_lngth, 1, m_lngth

left m_var_name, m_lngth, m_var_name

check_file:

Concat res_directory, m_var_name, res_output_path_and_name

onerrorresumenext

ftpfilesize res_ftpserver, res_ftpuser, res_ftppassword, res_output_path_and_name, m_file_size

IFthen (m_file_size, transfer_file)

//the file was a directory go to the top_of_loop to get the next file

goto top_of_loop

transfer_file:

//ftpfileexists res_ftpserver, res_ftpuser, res_ftppassword, res_output_path_and_name, m_file_exists

//test the list of files to see if they are files or directories

FTPgetFile res_ftpserver, res_ftpuser, res_ftppassword, res_output_path_and_name, "F:\\claim"


Wed May 12, 2004 3:52 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: FTPFileSize and directories Reply with quote

Try using FTPDir in place of FTPFileSize. If it fails then you deal with a file and continue from there, otherwise you deal with a directory and so you should skip it advance to the next name in the list

For example

: hey,

: Using the FTPdir command how can I disseminate between files and directories
: with the returned results?

: I get a file list: file1,file2,file3,file4.
: File1 = dir
: File2 = dir
: File3 = file
: File4 = file
: I am performing a ftpdir command that returns “file1,file2,file3,file4”

: When I process file1 with FTPfileSize it is returning the a value even though
: it is a directory. I expected zero bytes back

: I want to process files meeting a file mask and discard the directories. Any
: suggestions??

: CODE sample: Dim res_output_path_and_name, string, "" //the
: returned file path and name of file Resolute will process.
: dim res_filemask, string, "fi*.*", //file mask to retreive from
: EPIC server.
: dim res_directory, string, "/dir1/dir2/claim/" //Directory to look
: in.
: dim res_path_mask, string, ""
: dim res_d_results, string, "" //Comma seperated list of files
: returned from the FTPDir command.

: //This is the list of files to be processed.
: dim res_res_lngth, number, "" //the length of the results file.
: dim m_lngth, number, "" // used to determin if a Claims files are
: in the
: dim m_var_name, string, "" // this is the variable returned from
: res_d_results.

: dim m_file_exists, boolean, "" //set to true if the name found is a
: file and not a directory.

: // /epic/resolute/claim directory

: ftpdir res_ftpserver, res_ftpuser, res_ftppassword, res_directory,
: res_d_results
: messagebox res_d_results
: length res_d_results, res_res_lngth

: LoopWhile res_res_lngth, e_loop

: top_of_Loop: length res_d_results, res_res_lngth

: instr res_d_results, ",", 1, m_lngth

: //this retreives the first file/directory

: left res_d_results, m_lngth, m_var_name

: subtract res_res_lngth, m_lngth, res_res_lngth

: right res_d_results, res_res_lngth, res_d_results

: instr m_var_name, ",", 1, m_lngth

: ifthen (m_lngth, chomp)

: goto check_file

: chomp: subtract m_lngth, 1, m_lngth

: left m_var_name, m_lngth, m_var_name

: check_file: Concat res_directory, m_var_name, res_output_path_and_name

: onerrorresumenext

: ftpfilesize res_ftpserver, res_ftpuser, res_ftppassword,
: res_output_path_and_name, m_file_size

: IFthen (m_file_size, transfer_file)

: //the file was a directory go to the top_of_loop to get the next file

: goto top_of_loop

: transfer_file: //ftpfileexists res_ftpserver, res_ftpuser, res_ftppassword,
: res_output_path_and_name, m_file_exists

: //test the list of files to see if they are files or directories

: FTPgetFile res_ftpserver, res_ftpuser, res_ftppassword,
: res_output_path_and_name, "F:\\claim"

Wed May 12, 2004 4:26 pm View user's profile Send private message
~Joe



Joined: 18 Dec 2003
Posts: 42

Post Re: FTPFileSize and directories Reply with quote

I am using FTpdir to get the filelist (did you look at the example?), the directories are being returned with the
FTPdir command.

~Joe

: Try using FTPDir in place of FTPFileSize. If it fails then you deal with a
: file and continue from there, otherwise you deal with a directory and so
: you should skip it advance to the next name in the list

: For example

Wed May 12, 2004 6:34 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: FTPFileSize and directories Reply with quote

Yes, I got it. I suggested that in place where you check whether the name is a file or directory using FTPFileSize you check it using FTPDir.

Anyway, what you are trying to do in your script could be possible done in one line of code using SyncFTPDir command. Hope this helps.

: I am using FTpdir to get the filelist (did you look at the example?), the
: directories are being returned with the
: FTPdir command.

: ~Joe

Wed May 12, 2004 7:24 pm View user's profile Send private message
~Joe



Joined: 18 Dec 2003
Posts: 42

Post Re: FTPFileSize and directories Reply with quote

Okay, I will look into the syncFTPdir

: Yes, I got it. I suggested that in place where you check whether the name is
: a file or directory using FTPFileSize you check it using FTPDir.

: Anyway, what you are trying to do in your script could be possible done in
: one line of code using SyncFTPDir command. Hope this helps.

Thu May 13, 2004 2:08 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.