Posts Tagged ‘ batch

Windows 32 (x86) or 64 (AMD64) detection in batch files

While there are a lot of ways to detect for a 64 bit version of . you can test for %programFiles(x86)%, but handling the output and writing the IF comparisons is messy.

In files, you can easily check for architecture by using the “processor_architecture” variable. x86 versions of windows will have this set to “x86″, and x64 versions “x64″. Heres an easy example:

@echo off
IF %processor_architecture% ==  echo This is a 64-bit version of windows
IF %processor_architecture% == x86 echo this is a 32-bit version of windows.
pause

Batch extract a directory full of split RAR archives “part1″, “part2″

If for some reason you have a directory full of archives, and each is into parts, extracting them individually can be a pain. If you just type “ *” into the terminal, you will each file multiple times depending on how many “parts” it has. First, install the “unrar” package:

sudo aptitude install unrar

then cd to the directory with all of your RAR archives. Then type:

unrar e '*..rar'

make sure to keep the single quotes.
If the rar is password protected, add the “-p” switch followed by the password without any spaces.

unrar e -p
 '*.part1.rar'