Jump to content

need help with batch. how to address spaces in directory names?


Recommended Posts

I have a large directory structure that contain many zip files. In order to free up some space, I want to delete any unzipped files. I wrote a batch file that works OK. It looks for all zips and executes rmdir for every file name minus the extension. (a little sloppy but gets the job done)

The problem is, it misses any zips contained in folders that have spaces in the name. I know quotes are needed.... anyway, heres what I'm using:

FOR /f %%A IN ('dir /B /S "*.zip"') DO rmdir /S /Q "%%~dpnA" 

It cuts off anything beyond a space even thoumgh the executed rmdir commands show quotes around the directory names.

any ideas? different approaches to my problem?

being able to remove all spaces in the directory names or replace them with an underscore would also work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy