How can I delete files less than 100 bytes from the folder?

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.

@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. :smiling_face_with_tear:

empty

I’d like to make the file deletion criteria a .shp file, is it possible?

For example, if A_a.shp is 100 bytes,
Delete all A.A. (dbf / prj / qpj / shp / shx)

If B_u.shp is 150 bytes,
B_u (dbf / prj / qpj / shp / shx) all safe

@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

Only delete shp

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. :sweat:

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) + ".*"

@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