Invisible and/or unremovable files
I've downloaded a lot of files, from my Mac, via FTP.
A listdir gives the right list but some files are invisible in the Pythonista window.
These invisible files and some other (visible) ones can not be removed.
Has a file some attributes, and if yes, how to know them, and if possible, how to change them?
Files starting with a dot are hidden from the Pythonista file list, this is a Unix convention (though OS X and Pythonista enforce it more strongly than your average shell). You can rename them using
os.renameto not start with a dot, then you can see them in the file list. If you're having trouble deleting a file (visible or not), try deleting it using
os.remove- if that fails too, it will give you a useful error message telling you what the problem is. If it's a permission issue, use
os.chmodto change the file's permission bits.
Thanks, but they don't begin with a dot, and I use os.remove to remove them.
I'll try to understand os.chmod
Also, stash lets you list and delete such files (
ls -la). Easier than trying to rename them, or if you have lots in the same folder, you could use wildcards (
Thanks for your help, but it was, one more time, a programmation error.
I'll become a big specialist of the 17th line of @jonB 😢
My script compares my 25000 files, local vs Mac, by checking their size and ctime on both sides.
As the FTP scan of the Mac takes 8 minutes, I store the list of the remote files in a local file (of course, upon request, the script is able to rescan the remote server and recreate this file). The file is the str(dict) and the dict contains size and crime of both sides, and my bug has been to also store the local data in this file, thus I "believed" that the file did still exist because my script showed its size/ctime even if the file was no more existing... Sorry for your time, but at least, I'be learned chmod and ls in stash.
Do you think I need to entirely remove this topic or do I let it as "mea culpa"!