Five Stars

tFileCopy - not working, if file is used by another process

Hallo,
I want to copy excel-files with "tFileList - iterate - tFileCopy".
In previous versions it works, although an excel-file, listed in tFileList-directory, is used.
Now I get the following message:
Starte Job J011_V1_Kopieren_aus_Verzeichnis am 19:45 10/01/2017.
connecting to socket on port 3707
connected
Exception in component tFileCopy_1
java.io.FileNotFoundException: C:\Users\Administrator\Desktop\Aufgabenmanagement-AM\Bereich 1\Aktiv\~$B1-PMT-Beruf und Familie - V7 - TESTKOPIE.xlsm (Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at org.talend.FileCopy.copyFile(FileCopy.java:40)
at am_sammeln_v1.j011_v1_kopieren_aus_verzeichnis_0_1.J011_V1_Kopieren_aus_Verzeichnis.tFileList_1Process(J011_V1_Kopieren_aus_Verzeichnis.java:476)
at am_sammeln_v1.j011_v1_kopieren_aus_verzeichnis_0_1.J011_V1_Kopieren_aus_Verzeichnis.runJobInTOS(J011_V1_Kopieren_aus_Verzeichnis.java:758)
at am_sammeln_v1.j011_v1_kopieren_aus_verzeichnis_0_1.J011_V1_Kopieren_aus_Verzeichnis.main(J011_V1_Kopieren_aus_Verzeichnis.java:617)
disconnected
Job J011_V1_Kopieren_aus_Verzeichnis endet am 19:45 10/01/2017.

I installed the program "tFileList - iterate - tFileCopy", because I cannot ensure that all files are closed.
Have anyone an idea, how I can copy a file although it is open/in use?
Thanks for your help
Stefan
7 REPLIES
Moderator

Re: tFileCopy - not working, if file is used by another process

Hi,
Have you tried to use tfilelist-->tfilearchive-->tfilecopy? In this way, you can move the zipped file.
Best regards
Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tFileCopy - not working, if file is used by another process

Hi Sabrina,
thanks for your proposal. But it does not work.
In the folder of tFileList_1 there are EXCEL-files. It is working, if all excel-files are closed. If one excel-file is in use, it is not working and you get the following message:
Starte Job J011_V1_Kopieren_aus_Verzeichnis am 09:52 11/01/2017.
connecting to socket on port 3823
connected
Exception in component tFileArchive_1
java.io.IOException: This archive contains unclosed entries.
at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.finish(ZipArchiveOutputStream.java:415)
at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.close(ZipArchiveOutputStream.java:808)
at com.talend.compress.zip.Zip.doZip1(Zip.java:172)
at com.talend.compress.zip.Zip.doZip(Zip.java:109)
at am_sammeln_v1.j011_v1_kopieren_aus_verzeichnis_0_1.J011_V1_Kopieren_aus_Verzeichnis.tFileList_1Process(J011_V1_Kopieren_aus_Verzeichnis.java:494)
at am_sammeln_v1.j011_v1_kopieren_aus_verzeichnis_0_1.J011_V1_Kopieren_aus_Verzeichnis.runJobInTOS(J011_V1_Kopieren_aus_Verzeichnis.java:919)
at am_sammeln_v1.j011_v1_kopieren_aus_verzeichnis_0_1.J011_V1_Kopieren_aus_Verzeichnis.main(J011_V1_Kopieren_aus_Verzeichnis.java:778)
disconnected
Job J011_V1_Kopieren_aus_Verzeichnis endet am 09:52 11/01/2017.
I hope you have another idea
Thanks
Best regards
Stefan
Five Stars

Re: tFileCopy - not working, if file is used by another process

Hi Sabrina,
I tried to manage the problem with "XCOPY".
When I do this in the CMD-Editor, it is working (see file "B1_cmd-Editor"; here you see the editor and the command as well the copied files (in folder test_ziel). Also you see the open excel-file).

Now I tried to realize this with Talend (command "tSystem") (see "B2-1_Talend_CMD_component"). The result after starting the job you see in "B2-2_Talend_CMD_result. The files are not copied.


What is wrong in my Talent-Job? The command works fine in the editor but not in the Talend job?
Thanks for your help.
Best regards
Stefan
Five Stars

Re: tFileCopy - not working, if file is used by another process

Screenshot B1_cmd-Editor
B1_cmd-Editor.pdf.pdf
Five Stars

Re: tFileCopy - not working, if file is used by another process

Screenshot B2-1_Talend_CMD_component
B2-1_Talend_CMD_component.pdf
Five Stars

Re: tFileCopy - not working, if file is used by another process

Screenshot B2-2_Talend_CMD_result
B2-2_Talend_CMD_result.pdf
Five Stars

Re: tFileCopy - not working, if file is used by another process

Hallo community,
I do not know, why the "tsystem"-command is not working, although the command is working in the cmd-editor. This problem is not solved.
But I managed the problem with the following activities:
Problem:

copy excel-file when the excel-file is open/in use

Solution:

create bat-file  with content "cmd /c xcopy /E  C:\Pfad\*.* C:\Zielpfad" (all files and directories are copied, even if they are open)
use "tsystem"-command with "cmd /c c:/Pfad/Datei.bat"
This is probably not the most elegant method, but it works. (To mention it again: tFileCopy is not working by opened excel-files)
If anybody have an idea, why "tsystem"  is not working directly with "cmd /c xcopy /E  C:\Pfad\*.* C:\Zielpfad" (see examples above), I would be glad to get some hints.
Best regards
Stefan