Can Anyone help me on move file path activity in studio. I used it before but for this usecase it is showing me an below error. studio activities
Hi @pari_patel
can u show the filepath please?
Sure. I want to keep first 8 characters as it is and rest of the characters will be change for each file. Also I want to move file with rename. Thanks in advance @NIVED_NAMBIAR
Path would be download folder path on windows.
Hi @pari_patel
i think that is reason for the issue
so better way is filter the file path based on patterns in file name
for eg , folder_1 is the path of folder where the file is present
now use assign activity
file_list = Directory.GetFiles(folder_1).Where(Function(file) System.Text.RegularExpressions.Regex.Matches(Path.GetFileName(file).ToString,ârc4jg3w_*â).Count<>0)
Now you will list of all files which matches the given file name patten
Regards,
Nived N
Thanks. Can you suggest another way? I am not able to get into this code.
Oh sorry
I forget to tell this shortest way to try out
U can try using this assign activitiy
file_list= Directory.GetFiles(folderpath,ârc4jg3w_*.txtâ)
the file list will be list of all filepath whose file name had the Pattern as u specified
rc4jg3w_*.txt
Ok. Then for each activity need to use?
Actually we can do using move file activity only because there needs to rename file while putting on destination folder.
You canât use wildcards in Move File. Youâd need to do a For Each, with Directory.GetFiles(path + â\rc4jg3w_*.txtâ) and within the For Each do the Move File.
@pari_patel - Your âFromâ should be âFileââŚ
Get rid of the Assign and the source variable. Just put the Directory.GetFiles expression into the âinâ box of the For Each.
Also, click the For Each activity and in its properties, change the datatype to string. Now file will have the path and filename of the file. This property being wrong is why youâre getting the âIllegal charactersâ error.
You just need to make sure Desti has the correct destination path and filename.
Destination path is correct and see below it is still showing me an error.
I used move file activity with one file and itâs working fine, but need to use wildcard as everytime file name should be different.
You donât use a wildcard in the source path of the Move File. It doesnât work that way. Disable the Move File activity and put in a Log Message activity so itâll output the value of the file variable. Did you set the datatype of the For Each to string?
Sorry, I gave you an incorrect expression. It should beâŚ
Directory.GetFiles(path,ârc4jg3w_*.txtâ)
path should be just the path to the folder these files are in.
Thank You.
I used Directory.GetFiles(path,ârc4jg3w_*.txtâ). Itâs working.
Any luck on fid out the file rename while moved to destination?
Hi @pari_patel
you can store the file renamed name in a variable and then access by that way
do you mean file names in the destination folder ??
you can use same method as mentioned by @NIVED_NAMBIAR and @postwick but for loop with destination folder
follow below pseudo code
for each item in Directory.GetFiles(Destination_folder_path)
FileName = New FileInfo(item)
message box FileName.Name
variable FileName variable type is FileInfo (Browse for type System.IO.FileInfo in variables panel)
note that, to get file name we need to give FileName.Name (i.e. var_name.Name) and not FileName.ToString
hope this is helpful
Hello Pari,
As we can use you have mentioned *( asterisk sign) which is consider to be a special charactor and you cannot have a file path/file name with *( asterisk sign).
Please consider removing the *( asterisk sign) to avoid the error.
If you find this information useful than mark this as solution and hit like icon.
Thank you so much .