[SOLVED] rmdir /S does not delete all files

geckovic02

Reputable
Jan 21, 2019
131
22
4,615
Hey!

Long story short: I want to delete all files from a folder. There are a few normal folders inside of it, aswell as .dat files.

Now the problem: A couple sites suggested that rmdir /S should delete all the files inside the directory. But for me, it only deletes the folders and not those .dat files.

Here's my coding:

rmdir "C:\Users\NAME\Desktop\1.8.9_Forge\world\" /S /Q

Can't find anything different than that, except really difficult coding, which I can't really comprehend.
It shouldn't be that hard to delete everything from a folder, right?

Maybe this could help a bit:

All I want to write, is a batch-file that stops my Minecraft server, deletes the current (destroyed) world, replaces it with an original copy and starts the server again.

Hope someone can help me
 
Solution
Plan it in more detail. For example, make a list of the directories, folders, and files that are to be deleted and then replaced by the copies. You will need the pathname to the location of the copies.

You will probably need to use wildcards: e.g., "*.dat".

Break the required actions into steps.

Then write the batch file with an action for each step.

General steps:

--- Stop the Minecraft server

--- Delete the files (DEL)

---Remove the directories (RMDIR)

--- Copy in the originals (COPY)

--- Restart the server



Command Reference:

https://www.lifewire.com/list-of-command-prompt-commands-4092302

https://www.lifewire.com/dir-command-4050018

You can easily find other command reference lists or google a...

Ralston18

Titan
Moderator
Plan it in more detail. For example, make a list of the directories, folders, and files that are to be deleted and then replaced by the copies. You will need the pathname to the location of the copies.

You will probably need to use wildcards: e.g., "*.dat".

Break the required actions into steps.

Then write the batch file with an action for each step.

General steps:

--- Stop the Minecraft server

--- Delete the files (DEL)

---Remove the directories (RMDIR)

--- Copy in the originals (COPY)

--- Restart the server



Command Reference:

https://www.lifewire.com/list-of-command-prompt-commands-4092302

https://www.lifewire.com/dir-command-4050018

You can easily find other command reference lists or google a specific command for more information.

Focus on one step at a time. And remember that there can be different/varying ways of achieving any given objective.

Apply switches as necessary.
 

geckovic02

Reputable
Jan 21, 2019
131
22
4,615
Plan it in more detail. For example, make a list of the directories, folders, and files that are to be deleted and then replaced by the copies. You will need the pathname to the location of the copies.

You will probably need to use wildcards: e.g., "*.dat".

Break the required actions into steps.

Then write the batch file with an action for each step.

General steps:

--- Stop the Minecraft server

--- Delete the files (DEL)

---Remove the directories (RMDIR)

--- Copy in the originals (COPY)

--- Restart the server



Command Reference:

https://www.lifewire.com/list-of-command-prompt-commands-4092302

https://www.lifewire.com/dir-command-4050018

You can easily find other command reference lists or google a specific command for more information.

Focus on one step at a time. And remember that there can be different/varying ways of achieving any given objective.

Apply switches as necessary.

After around 2h I found it:

Old code:

rmdir "C:\Users\NAME\Desktop\1.8.9_Forge\world\" /S /Q

New one:

rmdir "C:\Users\NAME\Desktop\1.8.9_Forge\world" /S /Q

That one backslash was causing it, not to delete everything.
 
Solution

TRENDING THREADS