Jump to content
azzajess

Useful Windows Batch Files to zip up Roms and other tasks

Recommended Posts

Hey everyone, I have assembled some useful Windows Batch Files to help with the automatic zipping for roms and other tasks.

To create the .bat file simply create a text document within Windows and name it what you would like and make sure the extension is .bat
Then you want to right click and press 'edit' in order to add text to the document. Simply copy and paste one of the following code and save it.
By default windows doesnt normally allow you to see extensions of known file types so you may have to do a quick Google Search on how to show file extensions on all files

If you would like to change the compression type to either 7z or zip, simply replace the extension where it says either .7z or .zip to the compression type you want.

Some of these file can/may be improved, as these arnt perfect, however they may help you like they have helped me.

NOTES
You must have 7z installed on the computer. I have included the default directory to 7z however double check your directory to make sure its in the same place, otherwise change it to the correct directory
All Batch files should be in the same directory you would like the operation, this means the .bat files are portable. So sometimes the Batch file may also be ziped up :| 

-----

BatchFolder2zip.bat

The below code automatically zips the files inside folders with the folders name. This is useful for zipping up Foldered roms but dont want to zip up the folder as well. This is useful for SkumVM if you wanted to convert your folder rom set to ZIP

for /d %%X in (*) do "C:\Program Files (x86)\7-Zip\7z.exe" a "%%X.zip" "./%%X/*"

Pseudo Code: For content inside every folder for any extension run 7z and add the contents inside folder and name the zip the same as the folder.

---------------------

BatchFile27z.bat

This automatically zips all files within the same directory of the batch file into a 7z. Useful for making NES or snes roms into 7z, or pretty much any standalone rom

FOR %%i IN (*.*) DO "C:\Program Files (x86)\7-Zip\7z.exe" a "%%~ni.7z" "%%i"

Pseudo Code: For the name of every file with any extension use 7z.exe to create a zip with the current name minus extension.

-------------------

BatchFilesInFolder27z.bat

So what this does is it puts all the files inside multiple folders in the current directory into a 7z file outside the folder. HOWEVER it only zips the files within the folder if they have the same name but can have different extentions. For example Folder name is Crash_Bandicoot and inside the folder is Crash Bandicoot (USA).bin and Crash Bandicoot (USA).cue. The batch file will automatically zip both files inside the folder (because they have the same name) and place the zip outside that folder called Crash Bandicoot (USA).7z. Just keep in mind, this will also automatically zip any other file with a different name in its own zip such as track01.bin files. etc

FOR /r %%i IN (*) DO "C:\Program Files (x86)\7-Zip\7z.exe" a "%%~ni.7z" "%%i"

Pseudo Code: For files inside directory with any extension use 7z to add files to 7z with name INSIDE folder pairing it up with files of the same name

------------------

BatchFile2Folder2Manual.bat

For every PDF/anyfile [Replace(*.pdf*) with (*.*) or for text files (*.txt*)] file, it will create a folder of the same name and then rename the file to Manual.pdf. It will then move that file into the folder.
This is useful for Manuals downloaded from EmuMovies Download Service as it downlaods the manual as the name of the game and to follow the structure of RocketLaunch, its normally in games name folder.

FOR %%i IN (*.pdf*) DO md "%%~ni" & ren "%%i" Manual.pdf & move Manual.pdf "%%~ni" 

Pseudo Code: For every file name that ends with .pdf, create a folder with the PDF file name without .pdf and rename the pdf file to Manual.pdf then move the file into the folder just created.

------------------

I am aware that there may be other utlities that can do the same thing such as Dons Rom Rename however these batch files may have other use cases and I am only sharing them because I found them useful, and it may help others as well. 

I would recommend that you test it on a smaller batch to test it out before converting your entire rom library

TIP: If you would like to see the progress when it finishes or want to debug it, Add      Pause         to the end of the code (Including a space and it is case sensitive)

If you have any useful batch files or improvements to the ones here, dont hesitate to share them.

Cheers

  • Upvote 4

Share this post


Link to post
Share on other sites

I wanted to say thank you for these valuable scripts and for saving me a ton of time with my Sega Saturn roms.  I had a single folder full of bin cue files and your batch file made quick work out of it.
Now I have a folder full of 7z files - right where I wanted to end up.

Thank you!

  • Upvote 1

Share this post


Link to post
Share on other sites
10 hours ago, Sncboom2k said:

I wanted to say thank you for these valuable scripts and for saving me a ton of time with my Sega Saturn roms.  I had a single folder full of bin cue files and your batch file made quick work out of it.
Now I have a folder full of 7z files - right where I wanted to end up.

Thank you!

My pleasure. I'm glad these scripts helped.

Share this post


Link to post
Share on other sites

Great work, Im currently working on a script to move genre artwork from a master folder to each system depending on what genre xml files are within that certain system.  Will hopefully release it in the next couple of weeks.

Share this post


Link to post
Share on other sites

This is great, I will save this post and work with some of them. Sometimes I find annoying tasks, like organizing my collection and then I think, "If I had a batch to do this, or if I knew how to make one". 

This is so helpful. Many thanks man

Share this post


Link to post
Share on other sites

Hi,

Just came up with a situation. Do any of you guys have a batch to rename a .7z file to match its internal file?

For example, I will use this scenario:

Crash Bandicot PSX.7z

----Crash Bandicot (USA).iso

----Crash Bandicot (USA).cue

 

I I'd like to rename the .7z name to match the .cue file (preferably). Like this:

Crash Bandicot (USA).7z

----Crash Bandicot (USA).iso

----Crash Bandicot (USA).cue

 

I Assume the .cue file is fine and matching the image. So no need to touch it.

Thanks

Share this post


Link to post
Share on other sites
6 hours ago, badboo said:

Just came up with a situation. Do any of you guys have a batch to rename a .7z file to match its internal file?

Crash Bandicot PSX.7z

----Crash Bandicot (USA).iso

----Crash Bandicot (USA).cue

I I'd like to rename the .7z name to match the .cue file (preferably). Like this:

Crash Bandicot (USA).7z

----Crash Bandicot (USA).iso

----Crash Bandicot (USA).cue

Hey, I don't think a batch file is able to rename based what's inside a zip without extracting it. There is however a neato program that can rename all sorts based off a database, including just naming zips/files or the files inside and then rezipping. The program is also able to rename the data inside the cue file. Anyway the software is

http://www.hyperspin-fe.com/files/category/446-romdatabaserenaming-tools/

Share this post


Link to post
Share on other sites
Hey, I don't think a batch file is able to rename based what's inside a zip without extracting it. There is however a neato program that can rename all sorts based off a database, including just naming zips/files or the files inside and then rezipping. The program is also able to rename the data inside the cue file. Anyway the software is
http://www.hyperspin-fe.com/files/category/446-romdatabaserenaming-tools/

Oh I see, in that case I will give that tool a try. Maybe this tool will help me with my issue. Thanks for your reply

Sent from my SM-G900W8 using Tapatalk

  • Upvote 1

Share this post


Link to post
Share on other sites
On 1/19/2017 at 10:04 PM, azzajess said:

-------------------

BatchFilesInFolder27z.bat

So what this does is it puts all the files inside multiple folders in the current directory into a 7z file outside the folder. HOWEVER it only zips the files within the folder if they have the same name but can have different extentions. For example Folder name is Crash_Bandicoot and inside the folder is Crash Bandicoot (USA).bin and Crash Bandicoot (USA).cue. The batch file will automatically zip both files inside the folder (because they have the same name) and place the zip outside that folder called Crash Bandicoot (USA).7z. Just keep in mind, this will also automatically zip any other file with a different name in its own zip such as track01.bin files. etc

FOR /r %%i IN (*) DO "C:\Program Files (x86)\7-Zip\7z.exe" a "%%~ni.7z" "%%i"

Pseudo Code: For files inside directory with any extension use 7z to add files to 7z with name INSIDE folder pairing it up with files of the same name

 

Hi,

I would like to do something similar to this. But how can I make, at the moment to 7z the folder to match the .cue file and take all the files inside, instead of separating them?

 

Edit: No worries, I managed to do this ;)

  • Upvote 1

Share this post


Link to post
Share on other sites
On 04/03/2017 at 1:08 PM, badboo said:

...how can I make, at the moment to 7z the folder to match the .cue file and take all the files inside, instead of separating them? 

Edit: No worries, I managed to do this ;)

Hey, sorry for the late reply, but did you create a new bat script to do the operation you wanted? If so feel free to share it :)

Share this post


Link to post
Share on other sites
19 minutes ago, azzajess said:

Hey, sorry for the late reply, but did you create a new bat script to do the operation you wanted? If so feel free to share it :)

Hey no worries, actually I couldn't find anything related to what I was looking for and I had to do it manually :(

That is why I mentioned that I managed to this, because I went the "one by one" way lol

But I will leave a link to this other contribution that was made by a member of this forum (@ci2own), and it has helped me out too. Here is the link:

Batch compress files inside folders

  • Upvote 1

Share this post


Link to post
Share on other sites

I am back again. I am in another situation lol.

So, this media for hyperpause. It is a lot of content by the way, like 350 gb. (for reference, you guys can go to youtube and search retrohumanoid. I didn't post the link because he has his reason not to, but you guys can go and find his channel. It is worth it).  But would only need a batch for the manuals section.

So I got a lot of manuals, hundred of them. They are in JPG. So I'd like to PDF all of them, because the pause takes a while to load all of these media, and maybe it is easy for it to read from a single PDF than hundred of pages in JPG.

Ok, so the structure goes like this: 

I have the folder "_Default", and in it are other folders with the name of the magazines, and in each folder are the JPG's. 

i.e.:

_Default/nintendo 12-1995/01.jpg

                                               02.jpg

                                                03.jpg

_Default/nintendo 12-1996/01.jpg

                                               02.jpg

                                                03.jpg

............and so on.

So, is there a way to have a batch and place it in the _default folder and pdf all these JPG's inside the subfolders and create the PDF with the name of the subfolder?

Thanks in advance.

Share this post


Link to post
Share on other sites
19 hours ago, badboo said:

So, is there a way to have a batch and place it in the _default folder and pdf all these JPG's inside the subfolders and create the PDF with the name of the subfolder?

Thanks in advance.

I don't think there is a way to do it via command line since it relies on a program to do some of the automating. In my case I was using 7z.exe which had particular parameters I could use. For your case the program would also need to support this if I'm correct. What program that is, I'm unsure. 

With that said there may be a program with a graphical interface that may allow you to batch convert your jpgs based off using the folders name. 

I would imagine that there is a program for doing this, it's a matter of finding it. Ill have a better look tomorrow for ya. 

Share this post


Link to post
Share on other sites
3 hours ago, azzajess said:

I don't think there is a way to do it via command line since it relies on a program to do some of the automating. In my case I was using 7z.exe which had particular parameters I could use. For your case the program would also need to support this if I'm correct. What program that is, I'm unsure. 

With that said there may be a program with a graphical interface that may allow you to batch convert your jpgs based off using the folders name. 

I would imagine that there is a program for doing this, it's a matter of finding it. Ill have a better look tomorrow for ya. 

Oh, then that is why I couldn't find anything like that. I spent a couple of hours or more looking for that, and nothing.

I downloaded a few programs also, but I can only go folder by folder. Which I rather go with the acrobat version that I have, because gives better quality.

The only thing close that I found, was in a forum where a guy there had the tool for that but he was charging $80 to everyone who was asking the same question as me. I rather do it folder by folder than paying $80.

Thanks for looking into that.

Share this post


Link to post
Share on other sites
On 14/03/2017 at 11:09 PM, badboo said:

Oh, then that is why I couldn't find anything like that. I spent a couple of hours or more looking for that, and nothing.

I downloaded a few programs also, but I can only go folder by folder. Which I rather go with the acrobat version that I have, because gives better quality.

The only thing close that I found, was in a forum where a guy there had the tool for that but he was charging $80 to everyone who was asking the same question as me. I rather do it folder by folder than paying $80.

Thanks for looking into that.

Perhaps we can have a two step method, first step is batch converting all the files in a folder to one pdf with any file name then setup a batch file that goes in and renames the files in all the folders with the folders name.

That is doable,  I believe so if we can figure out a batch convert so it converts the jpgs to a single pdf in a bunch of folders then we can do a rename script... 

Just a matter of finding a decent one. 

Share this post


Link to post
Share on other sites
9 hours ago, azzajess said:

Perhaps we can have a two step method, first step is batch converting all the files in a folder to one pdf with any file name then setup a batch file that goes in and renames the files in all the folders with the folders name.

That is doable,  I believe so if we can figure out a batch convert so it converts the jpgs to a single pdf in a bunch of folders then we can do a rename script... 

Just a matter of finding a decent one. 

That way of thinking sounds good. I am gonna do a research on that.

If a find this work around, then I will post it here.

  • Upvote 1

Share this post


Link to post
Share on other sites
On 1/20/2017 at 3:04 AM, azzajess said:

FOR %%i IN (*.*) DO "C:\Program Files (x86)\7-Zip\7z.exe" a "%%~ni.7z" "%%i"

I cant get this one to work @azzajess

EDIT: it's fine. Think I had it with single % symbols for some reason

folder structure

TEST

      --test1.txt

      --test2.txt

      --batchfile27z.bat

 

This one works but includes the extention in the new zip or 7z

 

 for %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\"

  • Upvote 1

Share this post


Link to post
Share on other sites

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.


  • Similar Content

    • By wishermill
      Hi everyone,
      I purchased HyperSpin platinum, donated to Emumovies for a yearly membership but when I try to run HyperSync Cloud.exe I get an error message:
      HyperSync encountered an error and needs to close, please see DEBUG.LOG for more details.
      If I open DEBUG.LOG I get the following details:
      System.Runtime.InteropServices.COMException (0x80040154): Clase no registrada (Excepción de HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
         en System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
         en System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
         en System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
         en System.Windows.Forms.AxHost.CreateInstance()
         en System.Windows.Forms.AxHost.GetOcxCreate()
         en System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
         en System.Windows.Forms.AxHost.CreateHandle()
         en System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
         en System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
         en System.Windows.Forms.AxHost.EndInit()
         en HyperSync.Forms.Secondary.Subscribe.InitializeComponent()
         en HyperSync.Forms.Secondary.Subscribe..ctor()
         en HyperSync.Forms.Primary.MainWindow..ctor()
         en HyperSync.Program.Main()
       
      Thank you for your help guys
    • By DrSoupants
      Dear Hyperspin
      I am having trouble renaming my MAME4droid (139.ui) rom files. There is more than one mxl file in the MAME directory and Don's Tools won't recognise any of the files in the 'roms' directory. What is the best way to rename these roms so they are compatible with Hyperspin? I am using the Nvidia Shield but I believe this to be irrelevant as this issue exists across all Hyperspin platforms. 
      Many thanks for your help in advance.
      Soup Pants
       
       
    • By koscica
      Hi I have and Hyperspin install on mounted network drive. HyperSync was working fine until I installed Windows 10 April 2108 update. I tried it on two PCs. It stops working after windows update. Any ideas?
      HyperSpin shows no internet connection available which is not the case
×
×
  • Create New...