12. September 2014 · Comments Off on Multi-boot UFD with Hi-Res Menus using Windows and Syslinux 6.xx · Categories: Batch Files, Graphics, Multiboot USB · Tags:
screenshot of main menuThis guide provides everything needed to create a customizable multi-boot USB flash drive in Windows with high resolution menus and customized splash screens. It provides a framework for creating a basic but functional multi-boot flash drive using Syslinux 6.xx as the primary bootloader. Basic menu configuration files and splash screen examples are provided. Experienced users shouldn’t find it difficult to follow this guide to create a ready-to-use bootable flash drive that can be customized to their needs. Users should already have some familiarity with Syslinux, installing Linux distros, and with formatting and partitioning flash drives.

For the sake of simplicity, this guide is limited to setting up Syslinux for a single partition using the BIOS modules. The instructions were tested and verified on a system running Windows XP SP3 and using Syslinux 6.02.screenshot of menu3 This guide is essentially a more up-to-date version and combination of two previous posts, Create a Multiboot Multipartition USB with Syslinux and Grub4Dos and Create Custom Grub4Dos, GRUB and Syslinux Compatible Splash Images.

Syslinux 6.xx

Syslinux provides two menu systems, the Simple Menu System and the Advanced Menu System. The advanced system must be compiled while the simple system includes the ready-to-use vesamenu.c32 and menu.c32 modules. This guide uses the vesamenu.c32 module.

Splash Screen Resolutions

Syslinux 6.xx can use splash screens in the .png or jpg formats at resolutions from 640×480 up to whatever is supported by the system. If the flash drive is going to be used on multiple systems, it would be best to use a typical resolution such as 800×600 that would work across most systems.

Modules

Since version 5.xx, modules are no longer stand alone or need additional libraries to work. A description of the changes can be found on the Syslinux Wiki at http://www.syslinux.org/wiki/index.php/Library_modules. In most cases, Syslinux will alert you of any additional libraries required when you try to use them.

(U)EFI (Unified/Extensible Firmware Interface)

Although there has been a lot of hype about (U)EFI (Unified/Extensible Firmware Interface) in general and support for (U)EFI began with Syslinux 6.xx, the (U)EFI modules are still fairly new, have a number of unresolved issues, and are not widely used at this time. UEFI in Syslinux is buggy and has problems on both Windows and Linux. Arch Linux describes some of the more relevant ones at http://wiki.archlinux.org/index.php/syslinux#Limitations_of_UEFI_Syslinux. Some of the issues with UEFI are:

  • UEFI Syslinux does not support chainloading other EFI applications like UEFI Shell or Windows Boot Manager.
  • UEFI Syslinux does not boot in Virtual Machines like QEMU/OVMF or VirtualBox or VMware and in some UEFI emulation environments like DUET.
  • Memdisk is not available for UEFI.
  • UEFI Syslinux application syslinux.efi cannot be signed by sbsign (from sbsigntool) for UEFI Secure Boot.
  • Using TAB to edit kernel parameters in UEFI Syslinux menu leads to garbaged display (text on top of one-another).

Other Syslinux issues/limitations:

  • Using Syslinux 6.02 on BTRFS volumes corrupts the superblock.
  • Syslinux cannot access files from partitions other than its own.
  • Using the memdisk module to boot most ISOs is often difficult or impossible.

Syslinux.org has admitted to these limitations and has often recommended other bootloaders such as GRUB, Grub4Dos, or Plop Boot Manager to compliment Syslinux. In spite of this, Syslinux remains one of the most functional and popular bootloaders not only for flash drives, but for other bootable devices like CDs, for most operating systems, and for chainloading partitions and hard drives. It’s very flexible and is an excellent choice as the primary bootloader for most situations. And by adding another bootloader such as Grub4Dos, this greatly enhances the flash drive’s booting options.

Creating a Multi-boot Flash Drive steps:

  1. Format the flash drive
  2. Install Syslinux 6.xx
  3. Install modules and files
  4. Install or create splash screens
  5. Customize menu configuration files (optional)

1. Format the Flash Drive

Format the flash drive with FAT16 or FAT32.

2.  Install Syslinux 6.xx

Download and unzip the latest .zip version of Syslinux 6.xx from Kernel.org. The file size should be about 12mB before unzipping. Open a cmd window and cd to C:\syslinux-6.xx\bios\win32. Type the following to install Syslinux to the flash drive where x is your flash drive:

syslinux.exe -sfma x:

This installs ldlinux.c32 and ldlinux.sys to the flash drive.

3. Install Modules and Files

Modules

Look for and copy the BIOS versions of the modules shown in the directory tree for the root of the flash drive. An easy way to locate the modules is to use something like AgentRansack. Modules have a .c32 extension (except memdisk) and are located in various folders in the C:\syslinux-6.xx\bios\com32 directory or C:\syslinux-6.xx\bios directory (for memdisk). Place all of the modules in the root directory of your flash drive. Copy the following modules:

chain.c32
cmd.c32
cpuidtest.c32
hdt.c32
ldlinux.c32
libcom32.c32
libgpl.c32
libmenu.c32
libutil.c32
meminfo.c32
menu.c32
memdisk
poweroff.c32
pwd.c32
reboot.c32
vesainfo.c32
vesamenu.c32

Configuration Files

The help text, menu.cfg, syslinux.cfg and other configuration files required can be downloaded from the configfiles download link below. Right click and using “save target link as” or similar (depending on your browser) to download it and then unzip and extract its files to the root of the flash drive.

  configfiles (9.8 KiB, 327 hits)

Download the latest version of Grub4Dos from grub4dos-chenall. Extract the grub.exe and menu.lst files to the root of the flash drive.

4. Install or Create Splash Screens

Install ready-made Splash Screens

To get started, splash screens tested to work with the configuration files are provided below. Just unzip them to the splashimages folder. After installing the splash screen images, the flash drive is ready to test or use.

Link for the splash screens: splashscreens

Nine (9) splashscreen files are provided. Download them as an album and extract to the splashimages folder. Slightly change the filenames by removing the number and dash so the filenames match those used in the menu configuration files.

The correct splashscreen filenames are:

  1. cave_800x600_14.png
  2. fallleaf_800x600_14.png
  3. grassyhill_800x600_14.jpg
  4. mist_800x600_14.png
  5. nightlight_800x600_24.jpg
  6. ny_800x600_14.jpg
  7. road_800x600_14.png
  8. Spruce_800x600_14.png
  9. winter_800x600_14.jpg.

The link below displays a directory of what the flash drive contents should look like at this point:

indexFlashDrive

Create and Install Customized Splash Screens (optional)

To create your own menu graphics, use the batch file below or another graphics program to create .png or .jpg format splash screens from your image files. Since the menus are already configured with light text, you may want to use a dark color to start off with. Generally, 14 colors works nearly every time and renders more quickly.

The batch file below is configured to use ImageMagick portable installed to the Utilities folder. If ImageMagick is already installed, simply change the line set IMdir=C:\Utilities\ImageMagick\ to your ImageMagick location. Use double quotes if the path contains spaces (e.g., set “IMdir=C:\Program Files\ImageMagick\”). Be sure to use the latest version of ImageMagick since the newest version has improved image conversion options and processing.

convert_syslinux_rev4b.bat

If creating a customized splash screen, place it in the splashimages folder in the flash drive and change the file name in the appropriate menu configuration file(s) as below so it can be used on the next boot:

MENU BACKGROUND /splashimages/your image name.jpg

5. Customize Menu Configuration Files (optional)

After the flash drive is working properly, try to install bootable applications or Linux distros by modifying the boot options in the menu configuration files for Syslinux or in menu.lst for Grub4Dos. Some menu label entries are already provided in the Syslinux menus that were verified to work such as Slax, Grub4Dos, and a few others.

That’s it. If anything gets messed up, everything can just be reinstalled and started again from the beginning. Good luck.

 

References:

Syslinux – http://www.syslinux.org/wiki/index.php/SYSLINUX

Syslinux Menu – http://www.syslinux.org/wiki/index.php/Menu

Syslinux 6 Changelog – http://www.syslinux.org/wiki/index.php/Syslinux_6_Changelog

Memdisk – http://www.syslinux.org/wiki/index.php/MEMDISK#ISO_images

 

Share
Recreating directory structures can be a tedious and error-prone chore, especially if using the right-click method to create multiple structures and folders. This guide describes three methods to easily copy directory structures (without files) in Windows: (1) with the command line, (2) with GUI tools dedicated for that purpose, and (3) by configuring a freeware file manager, FreeCommander, to enable this function.

http://clker.com

Copying Directory Structures from the Command-line

For those comfortable with the command-line, two commands that can be used for this purpose are the Xcopy and Robocopy, both of which have tons of options. Although others, such as the FOR command could also be used, Xcopy and Robocopy are by far the most popular tools used for this purpose.

Xcopy

Xcopy is included in systems up to Windows 8. XCOPY stands for extended copy. It’s a more powerful version of copy with additional features that can copy files, directories, and whole drives. Note that although Xcopy is included with most versions of Windows, it has been deprecated in favor of RoboCopy.

To use Xcopy to clone a directory without files, use the following syntax:

xcopy /t /e "C:\Your Folder" "C:\New Folder"

/t = Copies the subdirectory structure, but not the files

/e = Copies subdirectories, including any empty ones

When using Xcopy with the above switches, you will be asked to specify whether the target is a directory or a file before the Xcopy command executes, but if the command is executed from a batch file, no user interaction is required.

Note: Xcopy doesn’t display any progress or completed operations information when executed.

Additional Xcopy commands can be found here.

Robocopy

Robocopy stands for “Robust file copy.” It’s a standard feature for Windows starting with Vista. It’s can also be installed in WinXP as part of the Windows Resource Kit.

To use Robocopy to clone a directory without files, use the following syntax:

robocopy "C:\Your Folder" "C:\New Folder" /e /xf *

same as above but without displaying the status:

robocopy "C:\Your Folder" "C:\New Folder" /e /xf * >null

same as above and creates a log (overwrites existing log):

robocopy "C:\Your Folder" "C:\New Folder" /e /xf * /log:yourlogfile.log

same as above and appends to log (appends to existing log):

robocopy "C:\Your Folder" "C:\New Folder" /e /xf * /log+:yourlogfile.log

/e = Copies subdirectories, including empty ones.

/xf = Excludes files matching the specified names or paths. Wildcards “*” and “?” are accepted

Additional Robocopy commands can be found here.

Note: Robocopy displays progress and completed operations information when executed as shown in the below screenshot.

Freeware GUI Tools for copying Directory Structures

Two easy-to-use GUI (graphical user interface) apps dedicated specifically to creating directory structures without files are TreeCopy and Miroirs:

TreeCopy – Portable and freeware. Runs on Win95 to Win8.

treecopy screenshot

Miroirs – Freeware. Requires installation. Runs on XP/Vista/Win7

Miroirs screenshot

xcopy Frontend – Freeware. Portable. Runs on Windows XP or later. Provides an overview of all available parameters and makes it easy to select the needed parameters. Each parameter can be activated by clicking on it. The finished command line can be copied or executed directly.

 

FreeCommander setup to copy Directory Structures

FreeCommander is a freeware file manager that can be configured to copy directory structures using a customized batch file with the Xcopy and/or Robocopy commands. FreeCommander Ver. 2009.02b was used for this example. These instructions are modified from those provided on the FreeCommander forums.

FreeCommander Instructions

Create a batch file with the following code and save it with any name desired such as “copyFolderStructure_freecommander.bat.” For Xcopy the batch file’s main code consists of:

xcopy %1 %2 /t /e

%1 and %2 are the first and second parameters passed to the batch file (structure to copy and target)
The /t and /e options are the same as above

For Robocopy the batch file’s main code consists of:

robocopy %1 %2 /e /xf *

%1 and %2 are the first and second parameters passed to the batch file (structure to copy and target)
the /e and /xf * options are the same as above

Note: a pause can be entered at the end of either of the batch files above to keep the command window open for viewing the output

Example batch files for FreeCommander:
copyFolderStructure_freecommander_xcopy.bat
copyFolderStructure_freecommander_robocopy.bat

From the menu, select Extras->Favorite Tools->Edit or use (SHIFT+CONTROL+Y). Click the image below to enlarge.

freecommander menu

Select none from the left-hand column named Categories, then click once in the Items column.

FreeCommander Tools Configuration

Use the Items:Add to list button that appears above the Items column to create an item, for instance Copy Folder Structure.

Select Seek program by clicking the blue arrow next to the program field to navigate to and select the saved batch file’s (e.g. C:\tools\copyFolderStructure_freecommander_robocopy.bat) full path into the program field.

Enter the following into the parameter field:

"%LeftDir%" "%RightDir%" %Dlg%

The variables, %LeftDir% and %RightDir%, pass the address of the left and right folders to batch file parameters %1 and %2. The %Dlg% variable is optional and may be omitted if desired. It is used to display a Run program window (screenshot below) before actually starting the script to allow the folder names to be verified. It also provides a way for the operation to be cancelled.

dialog

If desired, add an icon by using the blue button next to the icon field to navigate to the icon’s location.

Make sure the boxes are checked as in the Define Favorite Tools screenshot above before hitting OK.

Tool Selection
The toolbar now contains an entry for copying Folder Structures. The tool can be selected from the menu with Extras->Favorite Tools->Name of your tool or by using the favorites icon (make sure Extras is enabled in Extras->Settings->View->Toolbar if it’s not visible on the toolbar).

Using FreeCommander

To use, select the structure to copy in FreeCommander’s left pane and select the target directory in the right pane. Select and click your tool from the toolbar or menu as described above. After the Run program dialog appears, click OK to continue.

FreeCommander Select

Xcopy doesn’t provide an option to display progress or completed operations. However, with Robocopy, the output will display the copy operation details as shown below (a pause was used in this batch file):RoboCopy Output

If no errors occur, the folder structure will be copied as in the following screenshot:

FreeCommander copied

Share

This guide describes the use of the WinRAR command-line tools (v5.01) for compressing and uncompressing files in a directory and their use in batch files. This guide is an extension of a previous post, Automate Zipping Tasks using the Command-line Interface that explained the use of the command-line tools for two free compression utilities, IZArc and 7-Zip. The information in this guide was tested on a Windows PC running Vista.

compression represented by a vise

WinRAR is a popular and powerful archive manager that can be used from the command-line or with scripting languages such as batch files. It includes two command-line tools, rar.exe and unrar.exe, where rar.exe compresses and unrar.exe uncompresses files. Both are located in the “C:\Program Files\WinRAR” folder in the installable version. Although WinRAR is shareware, it can be used on a trial basis for 40 days. Using WinRAR’s command-line tools is similar to those for IZArc and 7-Zip. The syntax for using the WinRAR executables is:

RAR or UNRAR <command> -<switch1> -<switchN> <archive> <files...> <@listfiles...> <path_to_extract\>

To get a listing of the options for the rar and unrar commands, open a command window, cd to the WinRAR directory, and type rar or unrar and then press enter (rar /?  or rar help may also be used, use rar >rar_cmds.txt or unrar >unrar_cmds.txt to print the command options to a file). For more detailed information, open the rar.txt file in the WinRAR directory which contains the RAR console version user’s manual.

Examples to compress a folder:

rar a -r yourfiles.rar *.txt

creates archive yourfiles.rar and compresses all .txt files in the current folder

rar a -r C:\yourfolder\yourfiles.rar *.txt

creates archive yourfiles.rar in C:\yourfolder and compresses all .txt files in the current folder and its subfolders

rar a -r C:\yourfolder\yourfiles.rar C:\otherfolder\*.txt

creates archive yourfiles.rar in C:\yourfolder and compresses all .txt files in otherfolder and its subfolders

rar a yourfiles 

creates archive yourfiles.rar and compresses all files in the current folder, but doesn’t include subfolders (note lack of extension; WinRAR will use the default extension .rar)

“a” command. Adds to the archive

“-r”  switch. Recurses subfolders

Examples to uncompress a folder: 

unrar x c:\yourfile.rar *.gif c:\extractfolder\

extracts all *.gif files from yourfile.rar to c:\extractfolder\ (trailing backslash required) and restores the folder structure

unrar e c:\yourfile.rar 

extracts all files in c:\yourfile.rar to the current folder (folder structure ignored)

“x” command. Extracts with full paths

“e” command. Extracts and ignores paths

Compression example using Multiple Switches:

rar a -r -ep -u -df -x*.bat e_archive.rar c:\test\*.*

compresses all new or updated files from c:\test and its subfolders to e_archive.rar, deletes the files after they are added to the archive, and excludes any files with a “bat” extension,

“a” command adds to the archive

“-r”  switch. Recurses subfolders

“-ep” switch. Adds files to the archive without including the path information. Multiple can exist in the archive with the same name.

“-u” switch. Equivalent to the “u” command when combined with the “a” command. Adds new files and updates older versions of the files already in the archive

“-df” switch. Deletes files after they are moved to the archive

“-x” switch. Excludes the specified file(s) from the operation

Basic rules for WinRAR:

  • When files or listfiles are not specified, all files in the current folder are processed
  • When specifying all files in a folder, yourfolder or yourfolder\*.* are equivalent
  • Folder structures are automatically saved in archives (but not automatically extracted)
  • WinRAR uses the .rar extension by default, but that can be overridden by specifying the zip extension in the archive name
  • Switches and commands are not case sensitive and can be written in either upper or lower case

Another point is that WinRAR doesn’t appear to use the Windows path environment variable, so it must be specified either at a command prompt, set permanently in the environment variable settings, or specified in a batch file.

To set the Windows path environment variable temporarily at a command prompt or in a batch file, use the following command:

set path="C:\Program Files\WinRAR\";%path%

To set it permanently in the Windows path for your PC:

start–>Control Panel–>System–>Advanced system settings–>Advanced Tab–>Environment Variables–>System Variables–>Path–>Edit. Add the path ;C:\Program Files\WinRAR; to the end (don’t forget the single semicolons at the beginning and end). Hit OK three times.

Using WinRAR in Batch Files:

Two batch file examples are provided, The first (compress_rar_rev1.bat) provides several compression options such as such as compressing all files in a folder or a folder and its subfolders, with options to compress them into a single archive or individually and to include or exclude paths. The second batch file (uncompress_rar.bat) decompresses all .rar files from a folder and places the extracted files into another directory. Be sure to change the extension(s) to .bat before using either file. Both of the following batch files temporarily set the Windows path environment variable for the WinRAR folder when executed.

compress_rar_rev1.bat

uncompress_rar.bat

 

Share
Syslinux Boot Menu ScreenThis guide demonstrates how to quickly and easily create custom 640×480 splash images for Grub4Dos, GRUB, and Syslinux menus using the Windows version of ImageMagick. The information in this guide was tested with Grub4Dos ver 0.4.4, GRUB ver 0.97, and Syslinux ver 4.04. Both of these Grub4Dos and GRUB versions have nearly the same requirements for splash images so that the same images can be used by either one. The formats are xpm for GRUB/Grub4Dos and png/jpg for Syslinux.

This guide does not cover splash images for GRUB2, the newest version and replacement for GRUB, which only recognizes the .tga, .jpeg, and .png image formats. GRUB is now officially known as GRUB Legacy, and while no longer developed as of version 0.9x, it is still being supported and enhanced, so GRUB will continue to remain a very usable boot-loader for the immediate future. Syslinux graphical menus are generated using the vesamenu.c32 module, which must be included in the boot medium. Syslinux Hi-color menus, like GRUB and Grub4Dos menus, also use a 640×480 size splash image, but have slightly different requirements as explained below. Also, Grub4Dos and GRUB have some splash screen requirements that are not specified in the Syslinux documentation, so apparently those particular graphical attributes are either not applicable or have no limitations in Syslinux.

grub4dos menu screenThis is a quick and dirty method that was tested to work as specified for this guide. The aim of this guide is to quickly generate custom splash images from existing images rather than to create works of art. As such, the quality of the finished images largely depends on the initial quality and size of the original image files.

The requirements for Grub4Dos or GRUB splash screen images are:

  • The image must use the .xpm format (.xpm files are usually g-zipped for faster loading).
  • The image must be exactly 640×480 pixels in size.
  • The image can’t have more than 14 colors.

The requirements for Syslinux Hi-color splash screen images are:

  • The image must be in the .png or .jpg format.
  • The image must be exactly 640×480 pixels in size.
  • Image depth and number of colors requirements appear to be unspecified. For this guide, the depth is set to 16 bits and the number of colors is set to 14 in the ImageMagick convert command line to obtain a smaller file size. For some images, the user may wish to increase the number of colors for better quality results.

Tools:
In Windows, the only tools required to create splash images are the ImageMagick freeware graphical image suite and a text editor to create batch files such as notepad. ImageMagick is a command-line only tool that’s fairly easy to use. As a command-line application, commands are executable from batch files or with other scripting languages. The self-installing version of ImageMagick automatically sets the registry entries, making it possible to execute it from any directory. If using the portable version, the path variable needs to be set manually or specified in a batch file to achieve this functionality. ImageMagick portable for Windows, ImageMagick-6.7.4-Q16-windows.zip, was used for this guide and tested on PCs running Vista and WinXP.

Image files to convert:
In most cases, make sure images are in the .bmp, .jpg, or .png format and are 640×480 pixels in size or have the same aspect ratio (e.g. 800×600, 1024×768, etc.) before converting them. If images are in any other format or don’t have a 640×480 aspect ratio, re-size them and change the format to .bmp, .jpg, or .png before using ImageMagick. For Grub4Dos or GRUB boot menu screens, if another original image format is used, such as .gif, ImageMagick will process it without error, but the image may be distorted or render incorrectly. Files can easily be re-sized and converted to .bmp, .jpg, or .png formats using most graphical editing programs already on your computer. Note that the .png format usually results in a slightly smaller file size than the .bmp format.

Note: ImageMagick’s
resize operator is designed to produce the best possible result for the requested image size (i.e. 640×480) and ignores aspect ratio if image distortion occurs during the conversion process. Thus the re-size operator does not necessarily scale the image! That is why it’s important to use true 640×480 pixel images (or images with the same aspect ratio (e.g. 4:3) before converting them with ImageMagick. Make sure to verify image size after converting with ImageMagick. The final size of images must be exactly 640×480 to work as splash screens.
______________________________________________________________________________

Steps to Create Grub4Dos and GRUB Compatible Splash Images:

Step 1: Download and Install ImageMagick

Step 2: Convert Image Files into Grub4Dos or GRUB Compatible Images with the ImageMagick command line:

Open a command window in Windows by clicking the Start button, select RUN…, then type “cmd” and click the “OK” button. In the command window, navigate to the directory where the files are located and use the following command to convert each file to a Grub4Dos and GRUB compatible splash image:

convert -resize 640x480 -colors 14 filename.bmp filename.xpm.gz

To install a Grub4Dos or GRUB splash image in menu.lst:

  • Copy the splash image to your HDD (e.g. hdo, hd1, etc.) or USB (e.g. sda1, sdb2, etc.) in the default folder or in a folder of your choice
  • Edit the menu.lst file to reflect the location of the splash image:

    splashimage (hd0,0)/yourfolder/filename.xpm.gz

Batch file example:

Drag and drop single or multiple .bmp, .jpg, or .png images into the batch file to automatically convert them into GRUB or Grub4Dos compatible splash screen images. Click to open the file link in your browser and then cut and paste the code into a text editor or right click to download the batch file code. Be sure to change the file extension to .bat before using:

convert_oldgrub_grub4dos_rev2.bat (drag and drop a single file or multiple files into this batch file)

convert_grub_rev3a.bat (updated script with more options)
_________________________________________________________________________

Steps to Create Syslinux Compatible Splash Images:

Step 1: Download and Install ImageMagick

Step 2: Convert Image Files into Syslinux Compatible Images using the ImageMagick command line:

Open a command window in Windows by clicking the Start button, select RUN…, then type “cmd” and click the “OK” button. In the command window, navigate to the directory where the files are located and use the following command to convert each file to a Syslinux compatible splash image:

convert -resize 640x480 -depth 16 -colors 14 yourfile.bmp yourfile.png

Note: Increasing colors from 14 to a higher value in the above command can result in higher quality images, but also slightly increases the file size.

To install a Syslinux splash image:

  • Make sure the vesamenu.c32 module is installed to the boot medium (get it from the Syslinux com32\modules\ folder). Vesamenu.c32 is usually placed in the same folder or partition as the syslinux.cfg file.
  • Copy the splash image to your HDD (e.g. hdo, hd1, etc.) or USB (e.g. sda1, sdb2, etc.) in the default folder or in a folder of your choice
  • Edit the syslinux.cfg file to reflect the location of the splash image:

    MENU BACKGROUND /yourfolder/yourfile.png

Batch file example:

Drag and drop single or multiple .bmp, .jpg, or .png images into the batch file to automatically convert them into Syslinux compatible splash screen images. Click to open the file link in your browser and then cut and paste the code into a text editor or right click the link to download the batch file code. Be sure to change the file extension to .bat before using:

convert_syslinux_rev2.bat (drag and drop single or multiple files into this batch file)

convert_syslinux_rev3a.bat (updated script with more options)
____________________________________________________________________

References:

Fedoraproject.org wiki – How to create a custom syslinux splash

ImageMagick – Resizing Images

Syslinux.zytor.com – Comboot/menu.c32

 

Share
This guide demonstrates how to automate repetitive compression tasks using the CLI (command-line interface) or batch files with two popular free archiving tools, the command-line utility for IZArc (freeware) and the command-line version of 7-Zip (open-source). Batch files are used because they are fairly easy to create, popular and can operate on several versions of Windows and DOS. Although batch files (*.bat) are covered in this guide, other scripting languages may also be used.

You may be thinking, “why would anyone want to automate a compression task in the first place”? Previously, I had a similar attitude until I had a need to compress, copy, rename, and move files from the same folder regularly, so I looked for a way to automate this process to save time and reduce errors.

This guide covers the use of two free archiving utilities, the command-line add-on utility for IZArc and the command-line version for 7-Zip. These two utilities were chosen because they are free, work well, and include a CLI executable or have it available as a separate add-on (as for IZArc). Using either of these utilities to automate your archiving needs is fairly easy to do, costs nothing, and saves time. Although this guide is designed to enable the user to accomplish this task quickly and easily, it is assumed that the reader is already familiar with creating and using batch files and has some experience with using compression utilities. WinXP was used to verify the information in this guide.

Step 1. Download one of the following (32 bit versions were used for this guide)

The versions used for this guide were: 7-Zip Command Line Version 4.65, IZArc Version 4.1, and IZArc Command line Add-On Version 1.1.

Note: This guide uses the Command Line Version of 7-Zip (7za.exe), which is a stand-alone version of 7-Zip that supports only the 7z, cab, zip, gzip, bzip2, Z and the tar formats. The full version of 7-Zip (installable and portable versions) contains a command line executable (7z.exe) that is more full-featured and explained in the 7-Zip help files. The IZArc command-line utility is an add-on to IZArc and supports the zip, jar, bh, cab, and the lha formats.

Step 2. Install the utility and set the path variable

For 7-Zip:
Extract the 7-Zip file to a location of your choice, for example C:\7zip. For convenience and to make the 7-Zip commands available to the batch file, manually set the path variable for the chosen location, e.g., C:\7zip. To set the path, right click My Computer–>Properties–>Advanced Tab–>Environment Variables. In the System Variables Area, select path, then click the Edit button. Add “;C:\7zip;” (or your folder location) to the end of the line (don’t include the quotes and don’t forget the semicolon at the start and end). Hit OK three times.

For IZArc:
First, install the IZArc utility and then install the IZArc Command-line Add-on to their default locations (C:\Program Files\IZArc) by double clicking them. The IZArc Command-line Add-on will install the Command-line executables izarcc and izarce to the IZArc directory in C:\Program Files\IZArc. The Path Variable is not set automatically during the installation, so it must be done manually. To set the Path, right click My Computer–>Properties–>Advanced Tab–>Environment Variables. In the System Variables Area, select path, then click the Edit button. Add “;C:\Program Files\IZArc” to the end of the line (don’t include the quotes but don’t leave out the semicolon at the start). Hit OK three times.

Step 3. Test the installation

Open a CMD window by hitting the Start button, enter “cmd” and press “OK”. A command-line window will open. Type one of the following into the command prompt window:

For 7-Zip:
Type “7za” and then press ENTER. If installed correctly, you should see the usage commands for 7-zip as shown in the top left thumbnail (click the picture to enlarge):

For IZArc:
Type “izarcc” and then press ENTER. If installed correctly, you should see the usage commands for IZArc as shown in the top right thumbnail (click the pictures to enlarge and view content):

Note: For IZArc, the command-line executables are izarcc for the compression function and izarce for the extraction function. If you didn’t get one of the screens shown above, then check that the Path Variables are present and correct for the 7-Zip or IZArc installation.

Step 4. Create the batch file

There are many ways to create batch files: from the simple to the complex. For the sake of simplicity and to focus on quickly demonstrating the use of these two compression utilities, this guide includes two example batch files (one for IZArc and another for 7Zip) that will compress all files from a folder into a single zip archive with a unique date suffix, move the zip archive to another folder, and then delete the original files. The thumbnails above show the contents of the batch files for 7-Zip (bottom left) and IZArc (bottom right). Click to enlarge them to view the contents. For both batch files, the folder “testzip” contains the files to zip and the folder “testmove” is where the archive is to be moved.

Depending on which utility you wish to use, click one of the following links to open the batch file text in a new window where you can cut and paste it into your text editor or download it: testizarc.bat (IZArc) or test7ip.bat (7-Zip). Note: if you use either one of these batch files be sure to change the extension to .bat, create the “testzip” and “testmove” folders on your C: drive, and copy some files you want to zip to the “testzip” folder. Of course you can change either batch file for your own needs using a text editor to change the zip folder (testzip) and move folder (testmove) to folders of your choice.

7za command-line in the 7-Zip batch file (test7ip.bat):

7za a -tzip "C:\testmove\xxxx_%TODAY%.zip" "C:\testzip\*.*" -mx5
  • 7za – (required) this starts the 7-Zip command-line executable.
  • a – (required) command to add files to the archive.
  • -tzip – (optional) switch to set the type of archive; in this case, it’s a zip file (optional unless using another compression format).
  • C:\testmove\xxxx_%TODAY%.zip – (required) the name of the archive to create.[“testmove” is the folder where the archive is to be created. “xxxx” is the name of the archive (replace “xxxx” with desired name). “%TODAY%” is today’s date and time variable added to the zip archive name to insure a unique archive name is created each time the batch file is executed. The parentheses are optional unless there are spaces in the file path. Finally, “.zip” is the type of archive to be created.]
  • C:\testzip\*.* – (required) the files to be archived. All the files with an extension in the folder “testzip” (this includes any subfolders regardless of the “-r” switch setting, see use below).
  • -mx5 – (optional) switch to set compression method. In this case, it’s zip mode, compression level 5 (level 5 is normal compression which is the default level).

When using the zip format and normal compression, the optional switches can be eliminated and the command shortened as shown below:

7za a "C:\testmove\xxxx_%TODAY%.zip" "C:\testzip\*.*"

Concerning subfolders: Officially, the “r” switch is used for searching and unless included, recurse subdirectories is disabled. However, because of a glich in the program, the zip command always includes subfolders regardless of “r” switch setting in situations where all files in a folder are to be archived using the wildcards “*.*”. For this reason, the “r” switch is not used in any of the 7-Zip example commands in this guide. See 7-Zip forum topic or 7-Zip FAQ’s – Why doesn’t -r switch work as expected? for further information.

 

IZArc command-line in the IZArc batch file (testizarc.bat):

izarcc -a -cx "C\:testmove\xxxx_%TODAY%.zip" "C:\testzip\*.*"
  • izarcc – starts the izarcc compression executable.
  • -a – adds files to the archive.
  • -cx – sets the compression level to maximum.
  • C:\testmove\xxxx_%TODAY%.zip – the name of the archive to create.[“testmove” is the folder where the archive is to be created. “xxxx” is the name of the archive (replace “xxxx” with desired name).%TODAY% is today’s date and time variable added to the zip archive name to insure that a unique archive name is created each time the batch file is executed. The parentheses are optional unless there are spaces in the file path. Finally, “.zip” is the type of archive to be created.]
  • C:\testzip\*.* – the files to be archived. In this case, it’s all the files in the folder ” testzip” (this doesn’t include any subfolders unless the “-r” command is added, see usage below).

Additionally the izarcc switches “-r” (include subfolders) and “-p” (store relative pathnames) may be used:

izarcc -a -r -p -cx "C:\testmove\xxxx_%TODAY%.zip" "C:\testzip\*.*"

-r – recurse into subfolders (include subfolders)

-p – store relative pathnames (maintains directory structure)

Currently, the IZArc help file for the IZArc program, IZArc.chm, contains limited information for the izarcc (compress) or izarce (extract) command-line functions; however, the command-line Add-on utility does include a text manual (manual.txt) that explains the commands and includes some examples for their use.

Using List files

Added 03/05/2013

List files are files that contain a list of one or more files and/or directories separated by new line symbols. Both the 7-Zip and IZArc command line utilities can use list files for processing files and directories. 7-Zip uses UTF-8 encoding for list files by default, but the encoding can be changed at the command line using the “-scs” switch if necessary (see the command line version section in 7-zip.chm for further information).

The command line syntax for compressing files and/or directories with a list file:

For 7-Zip:

7za a -tzip "C:\Your Folder\yourarchivename.zip @"C:\Your Folder\yourlistfile.txt"
  • 7za – the 7-Zip command-line executable.
  • a – add files to the archive command.
  • -tzip – set archive type to a zip file (optional unless using another compression format).

For IZArc

izarcc -a -r -p -cx "C:\Your Folder\yourarchivename.zip @"C:\Your Folder\yourlistfile.txt"
  • izarcc –starts the izarcc compression executable.
  • -a – adds files to the archive.
  • -cx – sets the compression level to maximum.
  • -r – recurse into subfolders (include subfolders)
  • -p – store relative pathnames (maintains directory structure)

Examples for a list file and a batch file that illustrate using a list file with the 7-Zip and IZArc command line utilities are below. The batch file contains commands for both utilities using a single list file. Be sure to change the file and path names as appropriate for your situation and the batch file extension to bat before using:

zip_listfile.bat

mylistfile

Summary

It’s fairly easy to automate archiving tasks using a simple batch file using either of the two free utilities covered in this guide. For basic needs, the command-line utility for IZArc or the 7-Zip command-line version (7za.exe) should suffice. For more complex requirements, the full version of 7-Zip (7z.exe) contains additional features; allowing users to perform more sophisticated archiving tasks from the command-line.

For more information and examples for using the 7-Zip command-line, also see the following:

Dot Net Perl’s article, 7-Zip Command-line examples

Codejacked’s article, ZIP Up Files from the Command Line

The official 7-Zip Manual, 7ZIP manual & documentation


Share
Bear

Bad Behavior has blocked 315 access attempts in the last 7 days.