0

I have a batch script which unzip and renames each file.
Unfortunately I now need to keep the filename of the zip file it came from.

Example Jazz1.zip now unzips and the outcoming text file becomes 1.Jazz1.zip.txt.
So I want %%F to become %%F - 4- characters.

Unfortunately I want it to be Jazz1.txt.

::Setup the stage... SETLOCAL ENABLEDELAYEDEXPANSION SET folder=C:\P\DataSource2_W SET count=1 ::Action CD "%folder%" FOR %%F IN ("*.zip") DO ( "C:\Program Files (x86)\WinZip\wzunzip" %%F MOVE *.txt "C:\P\DataSource2_W\TextFiles\!count!%%F.txt" SET /a count=!count!+1 ) ENDLOCAL 

1 Answer 1

2

I do not understand what you are trying to do with the COUNT variable, nor do I understand how you are handling a ZIP file with multiple .TXT files.

But I do understand that you want the base name of each ZIP file, (name without the extension). That is easy - simply use the ~n modifier (type HELP FOR from the command prompt for more info).

So if %%F = Jazz1.zip, then %%~nF yields Jazz1

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.