Trying to delete a directory stored on a Windows server, from on a Mac, containing files created on the Mac, getting "Directory not empty"
I am trying to delete a directory stored on a Windows 2008 R2 server, mounted on a Mac as network home (10.8.5). The directory was created by Safari and stores temporary internet files. I need to be able to delete this folder on logout from a Mac bash script.
The Terminal on Mac shows the directory as empty:
36W-FacRm-02:History lwickham$ cd /home/lwickham/Library/Caches/Metadata/Safari/History
36W-FacRm-02:History lwickham$ ls -al
total 0
drwx------ 1 lwickham CGPS\Domain Users 264 Nov 8 09:24 .
drwx------ 1 lwickham CGPS\Domain Users 264 Nov 8 09:28 ..
However, on the Windows server it has a single 0kb file that doesn't start with a "." but yet is invisible to the Mac.
E:\FacultyHome2\lwickham\Library\Caches\Metadata\Safari\History>dir
Volume in drive E is FacultyUsers2
Volume Serial Number is 8C17-4EF3
Directory of E:\FacultyHome2\lwickham\Library\Caches\Metadata\Safari\History
11/08/2013 09:24 AM <DIR> .
11/08/2013 09:24 AM <DIR> ..
11/07/2013 04:28 PM 0 http?%2F%2Fwww.google.com%2Furl?sa=t&rct=
j&q=&esrc=s&source=web&cd=6&ved=0CFsQFjAF&url=http%253A%252F%252Fwww.usbanklocat
ions.com%252Fhsbc-bank-usa-96th-street-branch.html&ei=5vR7UtmXEPjfsATe0YCIBA&usg
=AFQjCNF9ypKbpYbXRng00FY3W8Y6cF1Tiw&bvm=bv.56146854,d.
1 File(s) 0 bytes
2 Dir(s) 514,231,967,744 bytes free
9ypKbpYbXRng00FY3W8Y6cF1Tiw&bvm=bv.56146854,d.1 File(s) 0 bytes2 Dir(s) 514,231,967,744 bytes free
All my attempts to delete the dir from the Mac have failed:
36W-FacRm-02:History lwickham$ rm -fr /home/lwickham/Library/Caches/Metadata/Safari/History/*
36W-FacRm-02:History lwickham$ rm -frd /home/lwickham/Library/Caches/
rm: /home/lwickham/Library/Caches//Metadata/Safari/History: Directory not empty
rm: /home/lwickham/Library/Caches//Metadata/Safari: Directory not empty
rm: /home/lwickham/Library/Caches//Metadata: Directory not empty
rm: /home/lwickham/Library/Caches/: Directory not empty
Solution 1:
Step 1, stop trying to admin a Windows server with Mac tools.
Step 2, access the Windows server through Remote Desktop, or psexec.exe, or Powershell Remoting, or something that can execute commands on the Windows server, or have the admin do it if you don't have access.
Step 3, run
C:\>rd /s /q E:\FacultyHome2\lwickham\Library\Caches\Metadata\Safari\History
That will recursively delete that directory and all files it contains. You can do it from the Mac as long as you're using a tool that remotely executes commands on the Windows machine.