-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunlock_files.sh
More file actions
executable file
·63 lines (50 loc) · 1.4 KB
/
unlock_files.sh
File metadata and controls
executable file
·63 lines (50 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#Recursively unlock all files in the Drive
unlockFiles(){
# add the list of properties to be removed
xattr -rd com.apple.FinderInfo $DRIVENAME/
xattr -rd com.apple.quarantine $DRIVENAME/
xattr -rd com.apple.finder.copy.source.inode#N $DRIVENAME/
xattr -rd com.apple.finder.copy.source.volumeuuid#N $DRIVENAME/
}
# Check for locked files
checkFiles(){
inUseFiles=$(ls -l@ $DRIVENAME/* | grep -B1 "com.apple")
if [ "$inUseFiles" = "" ]; then
echo "[WARNING] Device already clean. Nothing to do here"
open "$DRIVENAME"
exit 0;
else
echo "$inUseFiles"
fi
}
#Check sudo
checkSudo()
{
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "This script should be run as ROOT. Try sudo"
exit
fi
}
echo "__________________________________________________"
echo "Abhinav.Y 2015 --abhinav56321(at)gmail.com--"
echo ""
echo "Initialize a NTFS Hard Disk on this system to fix the 'File in use Issues'"
echo "Run this script to release the Quarantine and FinderInfo locked files"
echo "Alternatively this script can be invoced as an FolderAction"
echo "Type Quit to exit the script"
echo ""
echo "__________________________________________________"
select DRIVENAME in "/Volumes"/*
do
case "$DRIVENAME" in
"$QUIT")
echo "Exiting."
break
;;
*)
echo "You picked "$DRIVENAME" "
checkFiles;
unlockFiles;
;;
esac
done