Questioning Everything Propaganda

Home Tags
Login RSS
PMview ICO to PNG
/* REXX Script: Batch Convert ICO to PNG using PMView on OS/2 */
/* Author: Jason Page */
/* Usage: rexx ico2png.rex [optional_directory] */

parse arg target_dir
if target_dir = '' then target_dir = directory()  /* Use current dir if none specified */

current_dir = directory(target_dir)  /* Change to target directory */
if current_dir \= 0 then do
    say 'Changed to directory:' target_dir
end
else do
    say 'Error: Could not access directory' target_dir
    exit 1
end

/* Find all .ICO files (case-insensitive, as OS/2 is) */
ico_files.0 = 0
call directory target_dir  /* Ensure we're listing from target */
temp_list = directory('*.ICO', 'N') || directory('*.ico', 'N')  /* Both cases */
if temp_list = '' then do
    say 'No .ICO files found in' target_dir
    exit 0
end

/* Parse the directory listing into stem array (format: "filename.ext size date time" ) */
do while temp_list \= ''
    parse var temp_list entry rest
    parse var entry filename size date time .  /* Extract filename */
    parse var filename name '.' ext  /* Split name.ext */
    if ext = 'ICO' | ext = 'ico' then do
        ico_files.0 = ico_files.0 + 1
        ico_files.ico_files.0 = name  /* Store base name without ext */
    end
    temp_list = rest
end

if ico_files.0 = 0 then do
    say 'No valid .ICO files found.'
    exit 0
end

say 'Found' ico_files.0 'ICO file(s). Starting conversions...'

/* PMView path - adjust if not in PATH or default install dir */
pmview_cmd = 'pmview.exe'

do i = 1 to ico_files.0
    input_file = ico_files.i || '.ICO'  /* Assume upper; adjust if needed */
    if stream(input_file, 'C', 'QUERY EXISTS') = '' then
        input_file = translate(input_file, 'ico', 'ICO')  /* Try lower */

    if stream(input_file, 'C', 'QUERY EXISTS') = '' then do
        say 'Skipping non-existent file:' ico_files.i
        iterate
    end

    output_file = ico_files.i || '.png'

    /* Build command: pmview /batch input output */
    conv_cmd = pmview_cmd || ' /batch "' || input_file || '" "' || output_file || '"'

    say 'Converting:' input_file '->' output_file
    rc = stream(conv_cmd, 'P')  /* Pipe to execute (OS/2 REXX pipes command) */
    if rc \= 0 then
        say '  Warning: Conversion may have failed (RC=' || rc || '). Check PMView config for auto-save to PNG.'
    else
        say '  Success.'
end

say 'Conversion complete. Processed' ico_files.0 'files.'
exit 0

Original Author: admin

Views: 38 (Unique: 28)

Page ID ( Copy Link): page_690bcb622f78e2.92534601-ed9e4245358add94

Page History (1 revisions):

  • 2025-11-05 22:12:32 (Viewing)