ParseRat is an old program that I have had a long time. I need to transpose text files in c:\wherefilesare.
I run the below and it just dies:
echo on
setlocal EnableDelayedExpansion
cd c:\wherefilesare
SET progdir=C:\program files (x86)\ParseRat
for%%x in (*.txt) do ("%%progdir%\parserat.exe" "%%x.txt" "%%progdir%\test.prz" "%%x.csv"
As #Squashman says:
"You (have) an extra percent symbol for all your (environment) variables. You are also not using the FOR meta-variable correctly. Essentially %%x expands to the actual file name with the extension. So it will see file1.txt.txt and file1.txt.csv. You need to use the command modifiers. %%~nx to get just the file name without the extension."
Also, you are missing a closing parenthesis...
echo on
setlocal EnableDelayedExpansion
cd c:\wherefilesare
SET progdir=C:\program files (x86)\ParseRat
for %%x in (*.txt) do (
"%progdir%\parserat.exe" "%%~nx.txt" "%progdir%\test.prz" "%%~nx.csv"
)
I followed the suggestions from this post on how to use the EnvInject plugin to create and set Jenkins environment variables. I'm using the "Inject environment variables" in post build step and set "Properties File Path"
The windows batch script create a environment variable OPS and writes it to a property file : results.txt which contains multiple lines , like :
OPS= This is line one,
This is two
This is three
Challenge: OPS picks up only the first line from results.txt and skips the rest of the lines.
How do I set OPS have all the lines as its value ?
cd C:\To\Test\Class\Path
java utilities.LogExtractor>ops.txt
#echo off
setlocal EnableDelayedExpansion
set LF=^
rem *** Two empty lines are required for the linefeed
FOR /F "delims=" %%a in (ops.txt) do (
set var=!var!!LF!%%a
)
set var=!var!!LF!
echo OPS=!var! > %JENKINS_HOME%\jobs\%JOB_NAME%\builds\%BUILD_NUMBER%\results.txt
and I set the "Properties File Path" to %JENKINS_HOME%\jobs\%JOB_NAME%\builds\%BUILD_NUMBER%\results.txt
From the source code, I'd say it uses java.util.Properties to load the file, calling the load method. The documentation says you can escape a line break with a backslash, so using
OPS= This is line one,\
This is two\
This is three
should be sufficient. (Be careful, whitespace at the beginning of the line is ommitted.)
I'd like to set a file's name to a variable in a batch file. I'm already pulling the file name by pulling the total path length. Is there a way I can parse the path to only give me back the file name?
The particular script that I use to pull the path looks like this:
for /f "delims=_" %%J IN ('forfiles /p "%%F" /m *.extension /c "cmd /c echo #path"')
DO start "Program" /D "c:\fullpath" /Wait program -r %%J
Also, if there's an easier way to pull the file name and put it into a variable I'm open to that as well.
To clarify it First i'm making a url shortener script that use input.txt file as input and outputs as an output.txt where you can put unlimited links in the input.txt
This is what i got
#echo off
set /p firstline=<input.txt
echo %firstline%
for %%a in (%firstline%) DO (
set "text=http://adfoc.us/api/?key=c803bc5b2f2e8ad5ccb0166d4bc898ae^&url=%%a"
)
echo %text%>output.txt
example input.txt has 600 lines and i want to make them all in output.txt
I assumed that you have an input.txt file that contain 600 lines with just the url part, and that you want to complete that lines with fixed http and key parts. If this is true, then the Batch file below do that:
#echo off
(for /F "delims=" %%a in (input.txt) DO (
echo http://adfoc.us/api/?key=c803bc5b2f2e8ad5ccb0166d4bc898ae^&url=%%a
)) >output.txt
Antonio
PS - If my answer is right, then you are NOT making an "url shortener script", but precisely the opposite thing! This script take an url and enlarge it by adding http and key parts, isn't it?
I can't figure out how to get my audio extractor script working via commandline arguments on ahk. I know the command line argument is correct, as I'm able to get it working through a batch file, but I keep getting the error below. I think I'm probably doing something wrong syntactically but I just can't figure out what.
I'd really appreciate any help. Thanks.
Error: the following variable name contains an illegal character"
channels=2,samplerate=44100}:standard{access="file",mux=dummy,dst="%A_LoopField%.mp3"}
Code:
fileselectfile, File_Name, M3
SplitPath, File_Name, name
Loop, parse, name, `n
if a_index = 2
{
msgbox, %A_LoopField%
Run, "C:\Program Files\VideoLAN\VLC\vlc.exe" "-I dummy -v %File_Name% :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access="file",mux=dummy,dst="%A_LoopField%.mp3"}"
}
Here is the original batch code if you're curious about the audio extraction function I was talking about
#ECHO OFF
REM Loop through files (Recurse subfolders)
REM Syntax
REM FOR /R [[drive:]path] %%parameter IN (set) DO command
REM
REM Key
REM drive:path : The folder tree where the files are located.
REM
REM set : A set of one or more files. Wildcards must be used.
REM If (set) is a period character (.) then FOR will
REM loop through every folder.
REM
REM command : The command(s) to carry out, including any
REM command-line parameters.
REM
REM %%parameter : A replaceable parameter:
REM in a batch file use %%G (on the command line %G)
FOR /R %%G IN (*.mp3) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.mp3.mp*) DO (CALL :SUB_RENAME "%%G")
GOTO :eof
:SUB_VLC
SET _firstbit=%1
SET _qt="
CALL SET _newnm=%%_firstbit:%_qt%=%%
SET _commanm=%_newnm:,=_COMMA_%
REM echo %_commanm%
ECHO Transcoding %1
REM Here's where the actual transcoding/conversion happens. The next line
REM fires off a command to VLC.exe with the relevant arguments:
CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -v %1 :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access="file",mux=dummy,dst="%_commanm%.mp3"} vlc://quit
REM Having no SLEEP-esque command, we have to trick DOS/Windows into pausing
REM for a bit between encode ops - To give the host OS a chance to do what it
REM needs to - Via clever use of the PING utility:
REM (Thanks to http://www.computing.net/answers/programming/dos-command-for-wait-5-seconds/11192.html for the tip! :-)
PING -n 1 -w 10000 1.1.1.1 > NUL
GOTO :eof
:SUB_RENAME
SET _origfnm=%1
SET _endbit=%_origfnm:*.mp3=%
CALL SET _newfilenm=%%_origfnm:.mp3%_endbit%=.mp3%%
SET _newfilenm=%_newfilenm:_COMMA_=,%
COPY %1 %_newfilenm%
GOTO :eof
:eof
REM My own little addition to prevent the batch window from "vanishing" without
REM trace at the end of execution, as if a critical error had occurred.
PAUSE
Have you tried without the SplitPath, File_Name, name? I got rid of the error like this, but I don't know if it produces the result you want in the end.
I found the answer. I was making syntatical errors I just didn't have the knowledge to fix myself. The new RUN statement works perfectly.
Here is the newly revised script
fileselectfile, File_Name, M3
SplitPath, File_Name, name, dir, ext, name_no_ext, drive
StringReplace, File_Name, File_Name,`n, \
Loop, parse, name, `n
{if a_index = 2
msgbox, %A_LoopField%
Run % "C:\Program Files\VideoLAN\VLC\vlc.exe -I dummy -v """ File_Name """ :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access=""file"",mux=dummy,dst=""" A_LoopField ".mp3""} "
}