Thank you for that - really helpful. Yes, rsync just updates OneDrive from USB every 10 minutes or so. I'd got so wrapped up in testing this outside of OneDrive, that I hadn't thought of some of the things you mention. Looking at my OneDrive folder with lsof, OD has handles on files that aren't open anywhere else. So, your idea of renaming on the USB stick is best. Plus, she has quite a lot of data.
In terms of the time and things happening whilst the script runs, I have 1,200 files in my OD and this script found and renamed about 40 in 0.12 seconds, which seems OK. The time hog is lsof, which takes about 13 seconds to run. This seems ridiculous compared to linux, but apparently it's a mac thing.
Anyway, I'll create a temp file with the lsof output for the tree, then grep for the current filename before proceeding further. I understand grep will return 0 if it finds something.
In reply to Re^3: Easy way to check if a file is open needed.
by Apt_Addiction
in thread Easy way to check if a file is open needed.
by Apt_Addiction
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |