The process of automatically uploading downloaded files from a web page to the same web page again

Is there a way to upload without specifying a file name? I automated the file download, but I want to know the process of re-uploading the downloaded file after that.
Even if I want to specify a file name to upload, it is difficult to build an algorithm because the downloaded file name is not the same every time. Please help me.

to sum up

Bring up the number(String) of data from the testdata(excel) then download 2 files(not same file name)
Reupload downloaded file (same page)
Can anyone tell me easily how to rename the downloaded file and put it in the designated folder from katalon? Video lectures related to this would be very beneficial.
I confirmed that It can be “rename” the file from the web browser…
But, When i record from katalon studio, " save as(rename) " can not be allowded…

I tried to make Custom Keyward like as

package renamefile

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testcase.TestCaseFactory
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import org.openqa.selenium.WebElement
import org.openqa.selenium.WebDriver
import org.openqa.selenium.By

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import com.kms.katalon.core.webui.driver.DriverFactory

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObjectProperty

import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper
import com.kms.katalon.core.util.KeywordUtil

import com.kms.katalon.core.webui.exception.WebElementNotFoundException
import java.io.IOException
import java.util.Arrays
import org.apache.commons.io.comparator.LastModifiedFileComparator
import org.apache.commons.io.filefilter.WildcardFileFilter

public class filename {

public static void main(String[] args) throws IOException {

FileRename fr= new FileRename()
File newfile = fr.getTheNewestFile(“C:\Users\hojun.lee\Downloads”, “csv”)
newfile.renameTo(new File(“C:\Users\hojun.lee\Downloads\dd.csv”))
String filename= newfile.getName()

System.out.println(“latest file is=”+filename)

FileRename fr1= new FileRename()
File updated = fr1.getTheNewestFile(“C:\Users\hojun.lee\Downloads”, “csv”)
System.out.println(“Changed file name is =”+updated)
}

public File getTheNewestFile(String filePath, String ext) {
File theNewestFile = null
File dir = new File(filePath)
FileFilter fileFilter = new WildcardFileFilter("*." + ext)
File[] files = dir.listFiles(fileFilter)

if (files.length > 0) {
/** The newest file comes first **/
Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE)
theNewestFile = files[0]
}
}
}

But it does not work… "C:\Users\hojun.lee\Downloads " is download path that new file is downloaded on. i want to change new file to “dd.csv”.
Can you help me ?

Hi @hojun.lee, check out the following: https://blog.mrhaki.com/2010/08/groovy-goodness-simple-file-renaming.html

Where should I specify the path in which the file is stored?

I cant not specify the file name before renaming … how to handle it ?

Read this post from @Brandon_Hein: How to Resolve File Upload Issues

I read that but still hard to understand…

This may help you: https://m.youtube.com/watch?v=CtczRadptXc