How to delete empty files/spreadsheets in a directory ?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ivan Mich
am 4 Mär. 2021
Kommentiert: Walter Roberson
am 7 Mär. 2021
Hello,
I have a directory with milions of .xlsx files. The point is that I want to remove empty files. Is there a way to do it using a command in matlab? Instead of the fact that these files are empty, they have 10kb.
Could you please help me?
4 Kommentare
Walter Roberson
am 4 Mär. 2021
To clarify:
Files that have only one line of data should be deleted, but files that have more than one line of data should not be deleted?
Akzeptierte Antwort
Ivan Mich
am 5 Mär. 2021
Bearbeitet: Ivan Mich
am 7 Mär. 2021
5 Kommentare
Walter Roberson
am 7 Mär. 2021
if size(C,1) == 1 && size(C,2) == 1
delete(emptynew);
end
Weitere Antworten (1)
Fangjun Jiang
am 4 Mär. 2021
- run [STATUS,SHEETS] = xlsfinfo(FILENAME). Most likely, it will tell you there is only one sheet
- run [NUM,TXT,RAW]=xlsread(FILENAME). Most likely, isempty(NUM) and isempty(TXT) are both true
- delete(FILENAME)
2 Kommentare
Walter Roberson
am 4 Mär. 2021
Alternative to the second step:
C = readcell(FILENAME);
isempty(C)
For example,
[STATUS, SHEETS] = xlsfinfo(FILENAME);
if length(SHEETS) > 1; next; end %assume multiple sheet files are special
C = readcell(FILENAME, 'sheet', SHEETS{1});
if isempty(C); delete(FILENAME); end
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!