Rename extracted file based on zip file in Batch

时光毁灭记忆、已成空白 提交于 2019-11-30 22:34:52

Try this

md textfiles
for %%f in (*.7z) do (
7z e "%%f"
move *.txt textfiles\%%~nf.txt
)
xcopy textfiles\*.txt originalfolder
rd textfiles /s /q

Just make sure there are no existing text files in this folder and this should work. It just creates a temporary folder and moves all text files there (only the extracted one will be present at the time but this works as the filename is not known) and renames it to the zip file name.

After all the extractions and renames are done it just moves all the textfiles back to the original folder and deletes the temporary one.

Hope this helps.

for %F in (*.zip) do 7z e "%F" -so >"%~nF.txt" - provided there is only 1 file in in zip archive as you said (shown as if executed directly from command line, if used in batch use %%F)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!