Copy and rename a file with mule - file

I'm trying to set up a mule app that consists of two flows.
One that retreives files from an ftp to local folder.
The other one polling the same folder and uploads the file to another FTP-server and also copies
a file from a another local folder, renames the copied file to the same filename as the "FTP-file" but with another extension and also uploads it to the same FTP-server.
I've tried to set a variable with the incomming filename but I don't know how to
copy a templatefile and rename it from a local folder as in the flow below.
Any help is appreciated!

You can just set the outputPattern property on the file endpoint using the variable name.

The file endpoint has the attribute to serve this purpose.
<file:outbound-endpoint path="${destination_path}" outputPattern="[new filename to be given to the file ]" doc:name="File" >
</file:outbound-endpoint>
on a FTP endpoint also the outputPattern attribute can be set to the desired filename.
<ftp:outbound-endpoint host="localhost" port="21" responseTimeout="10000" doc:name="FTP" outputPattern="test.xml"/>
Hope this helps.

Related

Determine end of path with a wildcard in .bat

I'm trying to copy a folder with a variable path to a fixed path using a .bat file. Basically trying to retrieve a folder from a shared server to use it locally. The path to the variable location can mostly be solved by retrieving an user input. However, the user input will only cover a large part of the to retrieve path. At the end there is still a variable component. That's where I'm stuck. Is there any way to use a wildcard in .bat to retrieve a folder? Searching stackoverflow teaches me that it can only be used for files and not folders, is there a workaround?
Code:
#echo off
set /p enddirectory=enter your folder:
set fixedpath=C:\xxx\xxx\folders\
set endpath=%fixedpath%%enddirectory%\ (*wildcard to be added here)
Xcopy /e %endpath% "C:\xxx\localfolder"
For example:
Server path : C/xx/ABC-1234567
User input: ABC
Defining the first path of the server path works, how can I get the full path? (1234567 is variable)

Copy a file with a name criteria using WinSCP scripting

I have a Test folder that contains multiple file with two types of filenames as below:
Cycle2605.zip
Cycle2605_P.zip
Cycle2705.zip
Cycle2705_P.zip
What I manage to do is, move all the file from the folder to other server via WinSCP SFTP as shown in the code below.
open sftp://user:password#hostname/ -hostkey="ecdsa-sha2*******"
put D:\Users\AALADELA\Desktop\Test /cygdrive/d/VB_SHARE/astroQA/AFP/in
exit
But how do I move file that in the filename not contain _P to the destination instead of move all file?
open sftp://user:password#hostname/ -hostkey="ecdsa-sha2*******"
if <filename not contain _p> echo put D:\Users\AALADELA\Desktop\Test /cygdrive/d/VB_SHARE/astroQA/AFP/in
exit
You can exclude files matching certain pattern with -filemask switch:
put -filemask=|*_P.zip D:\Users\AALADELA\Desktop\Test /cygdrive/d/VB_SHARE/astroQA/AFP/in
Or you can pick only the files you want, if your file name convention allows, e.g.:
put -filemask=Cycle????.zip D:\Users\AALADELA\Desktop\Test /cygdrive/d/VB_SHARE/astroQA/AFP/in
In this case, it's easier to use a Windows wildcard directly in the source path:
put D:\Users\AALADELA\Desktop\Test\Cycle????.zip /cygdrive/d/VB_SHARE/astroQA/AFP/in/

dynamic input/output folder location in Camel's file component

As per https://camel.apache.org/file2.html, file component cannot be configured with dynamic input/output folder locations?
Is there any workaround/alternative for the same?
Thanks.
Regards
Senthil Kumar Sekar
For the file consumer
You can use a customer filter as dynamic selection of which directories/files to pickup. But the starting directory is configured once (hardcoded).
For that to change you would need to stop the route, and change the directory, and start the route again - if you want to attempt that direction.
For the file producer
The file name is fully dynamic you can just set a name as the file header you want. See documentation for details.
You can use the header CamelFileName also to dynamically set a directory. Slashes will be turned into directories.
Example: CamelFileName = "directory/dyn_subdirectory_n/myfilename.txt" will be placed into the directory "dyn_subdirectory_n" located in "directory". The filename will be "myfilename.txt".

duplicate file with different name and folder via batch

I want to copy a file to a user defined folder with different filename via batch file
Here folder path is supplied by argument
CODE
type abc > %1\\my_abc
but it does nothing than creating file in same folder
whats my mistake?
Why don't you use :
copy abc %1\my_abc

copy to output directory file delete

i find that to play video files using mediaelement, we need to set the file's Copy To Ouput Directory to Copy Always. is there any option to auto delete the file from the output directory after it has been used? because if there's hundreds of video that has been played by the application, then it will take a massive amount of storage, right? because from what i seen, this copy to ouput directory will create the duplicate of the files, from it's original source path. please enlighten me
You do not need to copy the files to the output directory, you can set the source as follows:
mediaElement.Source = new Uri (System.IO.Path.Combine(dirWithVids, fileName)
,UriKind.RelativeOrAbsolute)

Resources