Rename directory name using batch file

Status
Not open for further replies.

tomato

Beta member
Messages
1
Hi there,

I need help to rename all directories in a folder with the name structure as "BS2315_20070212_2039.zip" to "BS2315_20070212_2039" (ie i need to remove the ".zip" extension from all the directory names). These directories are created dynamically everyday from zip files which i unzip using the following batch file, hence the names of the directories is not known. I need a batch file which automatically changes the names of all the directories by removing ".zip" extension after unzipping the files using the batch file code shown below:

@echo off
xcopy c:\data_load c:\data_load_backup
cd c:\data_load_backup
for %%f in (*.zip) do unzip %%f -d c:\unzipped_data\%%f

Also, Is there any way by which we can parse directory names like a string and edit it. Hence use it later to rename the file name?

Something like..
for %%f in (*.zip) do (
unzip %%f -d c:\unzipped_data\%%f

--- set dirname as %%f
--- Edit dirname here..
--- rename %%f to dirname

)

Any help will be deeply appreciated..
Thanks
Nisha
 
Status
Not open for further replies.
Back
Top Bottom