Deleting a specific folder all over my HDD: with CMD?

vsdagama

Distinguished
May 12, 2008
501
0
18,980
Hey,

I have a bunch of drives as a backup to my Synology NAS, all drives are full of @eadir folders.
Some kind of indexing system.

How can I use command prompt to delete all @eadir folders in a certain folder?
Or is there any program that can do this?

thanks!
 
im not sure @ is name legal with command prompt.
if it is, then
try.

del c: folder/* will delete anything in c:folder
but if you use
del c: folder/@* it will only delete the folders with an @ in the first letter of the folder name.

if its not name legal then you will need an app that removes empty folders or just delete the top most folder that contains all the others and then create a new 1 with the same name.
 

vsdagama

Distinguished
May 12, 2008
501
0
18,980
None of that is working :s

Well I got 2 types of files:
- The @eaDir that could be deleted by simply searching them in explorer and deleting them all.
- The @eaDir folders that could not be deleted: they "Cannot find this item" when I try to delete them.

When I try to disable the read-only on them
I get "there has been an error." "Cannot find given file: "content of @eaDir"."

After spending quite some time looking for a solution, I got this command to run in cmd:

@Echo OFF
REM Important that Delayed Expansion is Enabled
setlocal enabledelayedexpansion
REM This sets what folder the batch is looking for and the root in which it starts the search:
set /p foldername=Please enter the foldername you want to delete:
set /p root=Please enter the root directory (ex: C:\TestFolder)
REM Checks each directory in the given root
FOR /R %root% %%A IN (.) DO (
if '%%A'=='' goto end
REM Correctly parses info for executing the loop and RM functions
set dir="%%A"
set dir=!dir:.=!
set directory=%%A
set directory=!directory::=!
set directory=!directory:\=;!
REM Checks each directory
for /f "tokens=* delims=;" %%P in ("!directory!") do call :loop %%P
)
REM After each directory is checked the batch will allow you to see folders deleted.
:end
pause
endlocal
exit
REM This loop checks each folder inside the directory for the specified folder name. This allows you to check multiple nested directories.
:loop
if '%1'=='' goto endloop
if '%1'=='%foldername%' (
rd /S /Q !dir!
echo !dir! was deleted.
)
SHIFT
goto :loop
:endloop

It is very good at deleting the normal folders (which I can also do via explorer searching)
But it cannot delete those other @eaDir folders...
I tried adding /f after the /s and /q part, not helping either.
 

Krispy_1

Commendable
Mar 17, 2016
2
0
1,510
Hi,

I have just managed to solve this problem! I had this problem after the HDD in my Synology NAS drive failed. Luckily was able to retrieve my files by creating a bootable USB drive with Ubuntu (there's a youtube video by techwiztime on this), and copied all my files onto the HDD in my PC.

Whereon I found tends of thousands of @eadir folders which I could not delete. I tried everything I could find in various forum threads, but Windows just will not find the files/folders. Even though it's displaying them in Explorer (turns out there are files in the subfolders with funny names that Windows and DOS don't like.)

Solution: I guessed that if the files were created by the Linux OS in the NAS drive, then I should be able to find - and delete - them using Linux, so... with the offending drive connected to your PC boot up Ubuntu, use Ubuntu's file explorer and simply search for "@eadir" and delete them all in one go from there. I've booted back up into Windows and the folders (and all the files in them) are indeed gone. Fuck yeah! :)

Now to buy a new HDD for my NAS drive...