Krmi
(Kerem)
March 4, 2025, 10:56am
1
Hi everyone,
in a location i have a files names like >
01.01.2025,
02.01.2025,
03.01.2025
everyday i copy last modified file and rename it as t-1
Does StudioX can help me about it?
I do these steps :
1.For Each File in Folder
2. Copy folder (currenth file, last modified)
but the question is > what should i write on “to” area in order to name it as
"last modified file name + 1 "
to make it short :
(if the name of last modified file in the addres was 01.03.2025,
then the new file name(copied) should be 02.03.2025)
lrtetala
(Lakshman Reddy)
March 4, 2025, 11:02am
2
Hi @Krmi
Try this
LastModifiedFile = System.IO.Path.GetFileNameWithoutExtension(CurrentFile.ToString)
NewFileName = DateTime.ParseExact(LastModifiedFile , "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture).AddDays(1).ToString("dd.MM.yyyy")
Regards,
1 Like
@Krmi ,
in To section of copy folder activity you have to mention the folder path where you want to see that folder
For your first part of the question
in a location i have a files names like >
01.01.2025,
02.01.2025,
03.01.2025
everyday i copy last modified file and rename it as t-1
Does StudioX can help me about it?
Try below workflow
This will rename the latest modified file in the above format
Note in the rename activity, open in advanced editor and give the value as Datetime.now.AddDays(-1).ToString(“dd.MM.yyyy”)
I am little confused on the second part of the question. Add some lights to your question please
Krmi:
but the question is > what should i write on “to” area in order to name it as
"last modified file name + 1 "
to make it short :
(if the name of last modified file in the addres was 01.03.2025,
then the new file name(copied) should be 02.03.2025)
Hi, @Krmi
DateTime.ParseExact(Path.GetFileNameWithoutExtension(file.Name), “dd.MM.yyyy”, Nothing).AddDays(1).ToString(“dd.MM.yyyy”) + Path.GetExtension(file.Name)
Try this expression.
Krmi
(Kerem)
March 4, 2025, 11:53am
6
hmm. i got how works function now.
okey, the question is i wanna copy it same location. but i want to change it name after copying process.
for example. last modified name is > 01.01.2025
robot should copy it and rename it
the last file name should be 02.01.2025
also these are folder. i wanna copy folder.
maybe, the function that i am trying is completely wrong. can someone help me from very beginning
the only thing that i want copy folder include subfolders/files but with another name.
Hi @Krmi
To get and manipulate the folder name (date:
currentFolderName = Path.GetFileName(sourceFolderPath)
currentDate = DateTime.ParseExact(currentFolderName, “dd.MM.yyyy”, Nothing)
newDate = currentDate.AddDays(1).ToString(“dd.MM.yyyy”)
–Use the Copy Folder activity:
Source:sourceFolderPath
Destination: Path.Combine(Path.GetDirectoryName(sourceFolderPath), newDate)
Krmi
(Kerem)
March 4, 2025, 12:55pm
8
this is studioX guys.
not UiPath…
here you can follow below approach,
first create new folder for temporary based. After that copy the folder to there after copied rename that folder by using rename folder activity.
Then again copy that folder and past to your original folder