4
2
This is in relation to this question .
Unfortunately, PowerShell scripts are disabled on the system I am working on. I can't even use a simple (Get-Content)
.
I did figure out how to do change specific strings within a specific PS file (thanks to the replies). However, I can only do it on one PS file at a time, and I had to edit the batch file itself by specifying the PS file's name (its hardcoded). All that's left is for the batch file to process ALL PS files within the same directory (no subdirectories).
Here is the code:
REM Start of Code
REM Auto-process PS files within a directory
REM Changes how PS files look when displayed
REM This batch file searches for instances of
REM "OldStringx" within the file and replaces it
REM with "NewStringx"
REM Thicken line width from 1 to 5
Set "OldString1=1 setlinewidth"
Set "NewString1=5 setlinewidth"
REM Change Courier font to Helvetica
Set "OldString2=Courier"
Set "NewString2=Helvetica-Bold"
REM To do: This batch file should process all PS files within
REM the same directory where the batch file is located
REM (Batch file and all PS files to be edited should be
REM found on the same path).
REM Specified below is the PS file to edit. Hard-coded for now.
set file="psfile_to_edit.ps"
@echo off
cd /d .
for /F "usebackq delims=" %%F in (`dir *.ps /b`) do set outFile="%%~nF_edited%%~xF"
(
for /f "skip=2 delims=" %%a in ('find /n /v "" %file%') do (
set "ln=%%a"
Setlocal enableDelayedExpansion
set "ln=!ln:*]=!"
if defined ln set "ln=!ln:%OldString1%=%NewString1%!"
if defined ln set "ln=!ln:%OldString2%=%NewString2%!"
echo(!ln!
endlocal
)
)>%outFile%
REM Convert edited PS files to JPG
REM This requires convert.exe to work
REM Currently commented out to debug above parts.
REM convert.exe %outFile% -autocrop %outfile:~0,-4%.jpg
REM End of Code
Fundamentally, I just want to make this code process all PS files within the same directory. Please help. And thanks in advance!
This code works! Thanks Endoro. I've been working on it for 2 weeks now, and you solved it in under a day. I am truly grateful. Kudos to you, and have a nice day! – Carla Hook – 2013-12-02T17:19:50.230