1.

Solve : determine file status..?

Answer»

Hello Everyone
Wish someone can help me to fix this issue

my Problem is .. I have a batch file which is running for every 15min and every time checks if the specified file exists in the given path or not ..

but, its not checking if the file is a 100% copied file or not .. 

which means in real time.. when some one is copying  a new file with same name in to the same folder.. the its taking arround 2-5min to copy the file 

suppose the batch file is called in this duration.. the batch file is just checking if the file exists or not
but batch file donot know if the file is 100% copied file or not .. so my batch file is failing after executing few steps
so before proceeding to the next steps i want to check if the file copy is in progress or is it completed , or the file is 100% copied file
 
It means user is trying to copy the file into the directory and my batch file is trying to read the data from the copying file

how should I tell my batch file to findout if the file is completely copied file or copy in progress file

wish some one can suggest me the way in which I need to move Quote

so my batch file is failing after executing few steps
so before proceeding to the next steps i want to check if the file copy is in progress or is it completed

How is it failing? If you are getting a message on the console, you can process that message and take directed action.

Need more specific information. Its reading the file name  and the file exists but the file copy is in progress.
but my next line of the code says.. if file exists.. .started reading the data from file..
but as the file is not copied completely.. its failing when it is trying to read data from the file.

The whole problem occurs only when batch file gets executed when the file copy is  to the destination folder is in progress

how should I find out that file copy is completed or not

is there any way to findout ? Quote
Its reading the file name  and the file exists but the file copy is in progress.
but my next line of the code says.. if file exists.. .started reading the data from file..
but as the file is not copied completely.. its failing when it is trying to read data from the file.

What program are you USING to read from the file? I'm surprised the OS would allow opening a file that is opened for output by another process. Perhaps you could take action based on an error code produced by your program.

 I am writing in the batch file and using the batch file in SSIS package Quote
my Problem is .. I have a batch file which is running for every 15min and every time checks if the specified file exists in the given path or not ..

but, its not checking if the file is a 100% copied file or not ..

which means in real time.. when some one is copying  a new file with same name in to the same folder.. the its taking arround 2-5min to copy the file

Are you referring to SQL Server Integration Services? Is this on a network? Part of the problem may be that the copy is OVERWRITING the previous version. The NTFS index may reflect the attributes of the old file which might explain why the file exist test gives a false POSITIVE result.

Any chance you could move the copy to the SSIS batch file? You could then check if the copy was successful and run SSIS.

The Windows copy command runs INSIDE the command shell. Only under certain conditions would you be able to see if the copy command was in progress and even then it would not be with batch language.

You might also have the script that does the copy set an parameter in a file as to whether a copy operation was in progress or not. You SSIS batch file could query this parameter to determine if SSIS runs.

Good luck


Discussion

No Comment Found