Solved

File Copy - Copy empty Folders


Userlevel 2
Badge +19

Good evening.

I need to copy all the content from a folder to another one. That means files and subfolders.

I have been able to copy any file or subfolder with files, but if the subfolder is empty, it is not copied.

 

I've been playing around with the filecopy_dest_dataset attribute, but no luck.

 

I bet is something obvious, but I'm stuck.

 

 

I'm using FME 2019.0.2 (64-bits)

Thanks for any help provided!

icon

Best answer by hollyatsafe 11 July 2019, 18:14

View original

10 replies

Badge +2

Hi @oscard,

In the Navigator under the Writer parameters please try changing 'Copy Subfolders' to Yes.

Userlevel 2
Badge +19

Hi @oscard,

In the Navigator under the Writer parameters please try changing 'Copy Subfolders' to Yes.

I already tried that, but the empty folders are being ignored.

Userlevel 2
Badge +19

As a workaround, I have ignored the File Copy and use a SystemCaller with the XCopy /E command.

 

 

I still would like to know if the same behaviour is possible with the File Copy.
Badge +2

I already tried that, but the empty folders are being ignored.

Hi @oscard,

I think the issue might be in how you are defining you file path, for example if I want to copy empty folder 'abc'

If

filecopy_source_dataset=\\Users\\hcoxon\\Desktop\\2018\\abc

 

folder abc will not be copied but if

filecopy_source_dataset=\\Users\\hcoxon\\Desktop\\2018

 

folder abc will be copied over.

 

This is because the FileCopy Writer looks at moving files or the contents of a folder - this means in order for 'abc' to copied it needs to be treated as a subfolder within the source dataset filepath. In your Directory and File Pathnames Reader I think if you expose the path_ directory_windows attribute to use as the filecopy_source_dataset this might work.

Userlevel 2
Badge +17

I think all subfolders including empty ones could be copied if you set the source root folder path to the "filecopy_source_dataset" and set Yes to the Copy Subfolders parameters in the File Copy Writer. See also the attached demo.

filecopy-writer-example.zip (FME 2019.0.2)

Badge +2

@oscard, Is it solved?

Userlevel 2
Badge +19

I think all subfolders including empty ones could be copied if you set the source root folder path to the "filecopy_source_dataset" and set Yes to the Copy Subfolders parameters in the File Copy Writer. See also the attached demo.

filecopy-writer-example.zip (FME 2019.0.2)

I could swear I had already tried this the other day... I guess my brain is functioning better now after the weekend rest.

 

 

Thanks! That works.
Badge +9

I think all subfolders including empty ones could be copied if you set the source root folder path to the "filecopy_source_dataset" and set Yes to the Copy Subfolders parameters in the File Copy Writer. See also the attached demo.

filecopy-writer-example.zip (FME 2019.0.2)

@Takashi Iijima​ @hollyatsafe​  I am not sure what I am doing wrong. I want to move folders after my workbench completes successfully. but I cant get this to do anything. I have my filepathreader set to the root of where i want to move the folder from. and both the source and dest set in the filecopy transfomer.

Badge +2

@Takashi Iijima​ @hollyatsafe​  I am not sure what I am doing wrong. I want to move folders after my workbench completes successfully. but I cant get this to do anything. I have my filepathreader set to the root of where i want to move the folder from. and both the source and dest set in the filecopy transfomer.

Hi @Brad Nesom​ ,

 

It looks like you have 'Redirect to FME Data Inspector' enabled in your workspace. This should be indicated when you run the workspace at the end of the log file. There is a warning section that states:

 

*** All writer output has been redirected to the Data Inspector ***

 

When this parameter is enabled features will be rerouted to the inspector/visual preview instead of being written out. Disable this setting by selecting Writers in the menu and unchecking 'Redirect to FME Data Inspector'. Alternatively, this setting can be found in the Navigator > Workspace Parameters > Reader/Writer Redirect. Once updated the FileCopy writer should now perform the copy.

 

Second, in your workspace, since you are manually setting the filecopy_source_dataset parameter under the User attributes in the filecopy writer feature type the FeatureReader is not actually doing anything and should be removed.

Badge +9

@Takashi Iijima​ @hollyatsafe​  I am not sure what I am doing wrong. I want to move folders after my workbench completes successfully. but I cant get this to do anything. I have my filepathreader set to the root of where i want to move the folder from. and both the source and dest set in the filecopy transfomer.

@hollyatsafe​ you were correct on both counts. however now i get 12 items skipped.

2020-12-30 14:00:29| 1.4| 0.0|WARN |File Copy Writer: Skipped 12 features that were missing source datasets

Just fixed it!

Thanks for the help

Reply