I’m creating a folder inside TEST folder by uploading a simple tekst (varCurrFileName is a holding text file name) file to it. like this
it works but I want to know that created folder name as I want to move some more files which is located on root of FTP . Means want to move files from “/” to “/TEST/22-04-2024 13:12:56” if that is the current created folder when i uploaded the file.
How to find the folder name and then move all files with for each loop. I tried but its not working.
can someone help.
The challenge here is that standard FTP commands don’t directly provide a way to retrieve the name of the newly created folder after uploading a file. However, we can achieve this using a two-step approach:
@Ellen you need to try this to and need to modify according to your test logic.
Approach 1: Storing the Folder Name During Upload (by Paul)
Assign Folder Name: Before uploading the file, use an “Assign” activity to construct the desired folder name dynamically. You can use the Now.ToString("dd-MM-yyyy HH:mm:ss") format to include the current date and time in the folder name.
Upload with Constructed Path: In the “Upload File” activity, set the “Remote Path” property to the folderName variable. This ensures the file is uploaded to the newly created folder with the timestamp.
Move Files Using Stored Name: After upload, you can directly use the folderName variable to construct the target paths for moving files from the root directory.
Approach 2: Using Enumerate Objects (by Ashok)
Enumerate Folders (After Upload): After uploading the file, use the “Enumerate Folders” activity within a sequence. Set the “Folder Path” property to “/Test” to list all subfolders within the “Test” folder.
Filter for Newest Folder: Use a “For Each” activity to iterate through the enumerated folders. Inside the loop, you can compare the folder creation time (obtained using system functions) with the upload time to identify the newly created folder.
Extract Folder Name: Once you identify the newest folder, extract its name and store it in a variable.
Move Files Using Extracted Name: Similar to Approach 1, use the extracted folder name to construct target paths for moving files from the root directory.
Choosing the Right Approach:
Approach 1 is simpler and more efficient if you can control the folder naming convention (using timestamps).
Approach 2 is more flexible if you need to handle scenarios where the folder name might not follow a predictable pattern.
Hi Team, I am having issues with FTP activity. Getting the below error when using Enumerate Objects’
Enumerate Objects: One or more errors occurred. (Unsupported object type encountered.)