Jump to content
LaunchBox Community Forums

batch 7z directories in a path to a new directory but 7z


lunatiq
 Share

Recommended Posts

I have a batch for command line script that will convert files to 7z to compress but I'm not sure how to do directory of directories. Maybe someone can help.

 

FOR /F "TOKENS=*" %F IN ('DIR /B /A-D "D:\Media\Roms\atari 2600"') DO 7z.exe a "D:\Media\Roms\atari 2600\New Folder\%~NF.7z" "D:\Media\Roms\atari 2600\%~NXF"

 

Edited by lunatiq
Link to comment
Share on other sites

I think what you're wanting to do is zip up each folder into its own zip (.7z) file.

 

Example:  this batch file will take these 3 folders 

image.png.5a41f75c42d5758a41cfaca9a05bb714.png

and create these 3 files

image.png.0c273b1b56234ab4ed9905bcee96b494.png

 

Place the batch file inside the folder that contains the subfolders you want to zip.  In my Example, the batch file would go inside the Games folder.

image.png.d5c3e6a1b0cb92e70267c3af99ce40ae.png

for /d %%X in (*) do ( 
	PUSHD "%%X"
	"c:\program files\7-Zip\7z.exe" a "..\%%X.7z" "*" 
	POPD
)
pause

The "pause" at the end is optional.  I put it there so that I can see that it's working, and 'worked' when completed (as in no errors).

Link to comment
Share on other sites

2 minutes ago, JoeViking245 said:

I think what you're wanting to do is zip up each folder into its own zip (.7z) file.

 

Example:  this batch file will take these 3 folders 

image.png.5a41f75c42d5758a41cfaca9a05bb714.png

and create these 3 files

image.png.0c273b1b56234ab4ed9905bcee96b494.png

 

Place the batch file inside the folder that contains the subfolders you want to zip.  In my Example, the batch file would go inside the Games folder.

image.png.d5c3e6a1b0cb92e70267c3af99ce40ae.png

for /d %%X in (*) do ( 
	PUSHD "%%X"
	"c:\program files\7-Zip\7z.exe" a "..\%%X.7z" "*" 
	POPD
)
pause

The "pause" at the end is optional.  I put it there so that I can see that it's working, and 'worked' when completed (as in no errors).

This is exactly what I was looking for.

  • Game On 1
Link to comment
Share on other sites

  • 3 weeks later...

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...