"delete" does not find a file?
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Danijel Domazet
il 13 Mag 2020
Commentato: Walter Roberson
il 13 Mag 2020
Why wouldn't this work:
if isfile(filename)
delete filename
end
filename is a char vector.
File is not deleted, and I get a warning: Warning: File 'filename' not found.
How could it be not found if isfile returned true? Am I doing some beginer mistake?
2 Commenti
Stephen23
il 13 Mag 2020
"Why wouldn't this work: "
Because you are using outdated, misleading, sadly overused command syntax.
Use function syntax instead.
Risposta accettata
Walter Roberson
il 13 Mag 2020
if isfile(filename)
delete(filename)
end
2 Commenti
Walter Roberson
il 13 Mag 2020
Look at the example,
delete *.mat
That is not going to ask MATLAB to look at all variables that are in scope and see if they are structs with field named mat, or objects with property named mat, or objects with method named mat, and then evaluate as appropriate in order to get the names of the files to delete. NOT done.
Instead it is treated as
delete('*.mat')
which tells it to delete all files in the current directory whose extension is .mat
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Software Development Tools in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!