Had an issue with some files of a moved drive and not able to delete them. so after a bit of hunting around found this.

 

How to take ownership of an expansion drive, flash drive or any drive for that matter on Windows 7 or 10 using the command prompt (CMD). Use this to take ownership then change permissions to everyone. This is useful when drive permissions get messed up and the drive gives you a permission denied or access denied error message. We will use the command prompt with elevated admin privileges.

  1. Go to search and type “CMD” without quotes.
  2. Right click and choose “run as admin”.

Now use the “takeown” command “takeown /f E:\* /r”. The command is “takeown”, the “/f” will force it, “E:\” is the location,  “*” means you want to do this for all of the E drive and finally “/r” mean do this for all files, folder and sub-folders.

 

Once “takeown” is complete you need to change permissions. You can do this with the icacls command. From CMD (the black box command prompt) you need to enter: E:\* /grant Everyone:F /t

If the recycle bin folder on the drive is loaded up it could be causing some of your pain, delete it with: rd /s e:\$Recycle.bin