Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to zip multiple text files in a folder in batch dont want want to use any other tools

i'm trying this
CD C:\Users\Documents\ArchiveUp
For /R %%G in (*.TXT) do 7za a -t7z "%%G" "%%~nG.7z"


i didnt work for me.
Could any one help me?
Posted
Updated 16-Dec-15 2:35am
v2
Comments
Sergey Alexandrovich Kryukov 10-Dec-15 10:20am    
You are missing main part of it, the application which would zip something... :-)
—SA
Member 12181658 10-Dec-15 10:46am    
like what would it be?
Sergey Alexandrovich Kryukov 10-Dec-15 10:55am    
Please see my answer, Solution 1.
—SA
Jochen Arndt 16-Dec-15 9:00am    
You have edited your question following the suggestions by Solution 1. But now this solution seems to be wrong.

You should have instead let the original command untouched and added the new one including a description why it is still not working. Don't forget that this will stay online and others may find it when searching for similar problems.

So I suggest to edit your question by reverting the changings and adding something like this:

[UPDATE]
I have the changed the command to:
For /R %%G in (*.TXT) do 7za a -t7z "%%G" "%%~nG.7z"

But I still got no success.
{Insert detailed description of what does not work here like error messages}

1 solution

Please see my comment to the question. You are missing the application or command with ZIP capabilities.

So, first approach is to have such application. I would recommend, first of all, open source 7-Zip:
https://en.wikipedia.org/wiki/7-Zip[^],
http://www.7-zip.org/[^].

Amazingly, there is no such thing in Windows which you could use directly in a command line or batch file, despite the fact that modern versions of Windows are certainly supplied with the ZIP capabilities hidden inside.

Strictly speaking, batch along is not capable of doing such thing, but the problem can be solved indirectly.

This is one of such solutions (sorry, I did not test it): http://superuser.com/questions/110991/can-you-zip-a-file-from-the-command-prompt-using-only-windows-built-in-capabili[^].

Essentially, this approach uses WSH under the hood: https://en.wikipedia.org/wiki/Windows_Script_Host[^].

WSH is used through JavaScript or VBScript programming and does not require any installations. So, why not using it directly? One of the ways to do so would be using .WSF file — please see a link below.

Generally, I would recommend to review your whole approach of using batch files, which are pretty much obsolete, hard to debug, and so on. How about using WSH directly, with .WSF file which you can use exactly as batch (also obsolete, but at least you can debug code). Anyway, you can simply click on this file to get it executed, as with a batch file, and don't need to install anything: https://en.wikipedia.org/wiki/Windows_Script_File[^].

Or you can use PowerShell, but you need to install it. Or some other application. Do you need archiving? What if this is not what you really need; maybe you need a Revision Control System instead, or something else? Just think about it.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900