Hello. I’m studying RPA, but I’m writing to get help because it’s difficult.
How can i Delete files less than 100 bytes from the folder…?
There are five file types in the folder. dbf / prj / qpj / shp / shx
.shp is less than 100 bytes, I want to delete all 5 type
ex) B_u.shp less than 100 byte B.dbf B.prj B.qpj B.shp B.shx delete all
ex ) C_u.shp more than 100 byte save all ( Even if C_u.qpj less than 100byte)
Please give me a lot of advice.
Anil_G
(Anil Gorthi)
January 6, 2023, 2:52pm
2
@oscar.o
Welcome to the community
Please check this
Size is in KB can be converted to bytes
cheers
2 Likes
Thank you for answer! But there’s a problem.
All the files are deleted.
I’d like to make the file deletion criteria a .shp file , is it possible?
For example, if A_a.shp is 100 byte s,
Delete all A.A. (dbf / prj / qpj / shp / shx)
If B_u.shp is 150 byte s,
B_u (dbf / prj / qpj / shp / shx) all safe
Anil_G
(Anil Gorthi)
January 10, 2023, 6:48am
4
@oscar.o
You can apply filter in the activity to filter only the required extensions
And for size as it is in Kb you have to convert 100 bytes to kb which is 0.1 kb so comparision should be with 0.1
Hope this helps
Cheers
1 Like
Thank you very much for your kind reply for the beginners.
Filtering has been applied.
However, that only the filtering case shp is deleted.
↓ that’s result of applying
A_A. shp 100byte less so delete
But i want delete all A_A file(dbf, prj,qpj,shx) because A_A.shp less than 100byte
B_B. shp 100byte more so all save it
Is there anything else I need to apply filtering?
It may be a basic question, but I’m sorry to keep bothering you.
ptrobot
January 10, 2023, 12:45pm
6
Test with this condition instead:
(CurrentFile.SizeInKB*1024) < 100
It converts the file size to bytes and then check if it’s less than 100 bytes.
Inside the If-block, use a second For Each File in Folder with a filter that matches the start of the filename:
filter = Path.GetFileNameWithoutExtension(CurrentFile.Name) + ".*"
1 Like
Anil_G
(Anil Gorthi)
January 10, 2023, 1:42pm
7
@oscar.o
This filters on .shp …instead remove the filter there and use a if activity in which you will check the extension.
Currentfile.extension should give it … {"shp","bdf"}.Any(function(c) currentfile.Extension.Contains(c))
and in then condition deete it.you can add all extensions
Cheers
1 Like
system
(system)
Closed
February 2, 2023, 1:04pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.