Applescript run on relative path - path

I'm running a quite stupid app, to clean my latex output files.
I'd like to place that app in every latex project i have, and be able to run that app. The app should detect its location based on where it is placed:
Ex: /Users/User/Documents/LatexProject1/clean.app to clean .../LatexProject1 Folder.
So far, I managed to run a script, based on absolute paths, which is quite annoying, having to change the app's path every time i run a new Latex project.
Can you help me to edit my code?
set subfolderOfSharedFolder to quoted form of "Users/lukas/Google Drive/006 semester/00_Bachelorarbeit/00_Documentation"
set response to display dialog "Trash all of the output files in your latex folder?" buttons {"Yes, I'm ready", "No"} default button 2 cancel button 2 with title "<subfolder name> Folder Prep" with icon caution
if button returned of response is "Yes, I'm ready" then
-- run spotlight search
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.lot c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.out c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.aux c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.blg c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.bbl c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.glg c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.glo c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.gls c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.idx c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.ist c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.lof c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.log c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.gz c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
-- run spotlight search 2
set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.toc c' -onlyin " & subfolderOfSharedFolder)
-- convert posix paths to file specifiers
repeat with thisFile in filesToDelete
set (contents of thisFile) to POSIX file thisFile
end repeat
tell application "Finder"
delete filesToDelete
end tell
if button returned of (display dialog "The APP files have been trashed." buttons {"OK"} default button 1 with title "SuchAndSuch Folder Prep" with icon 1) is "OK" then
end if
end if

"Path to me" gives the path to the script itself. Since you want the enclosing folder, you would use something like
tell application "Finder"
return folder of (path to me)
end tell
Edit to add: You would convert this line
set subfolderOfSharedFolder to quoted form of "Users/lukas/Google Drive/006 semester/00_Bachelorarbeit/00_Documentation"
to something like this:
tell application "Finder"
set subfolderOfSharedFolder to POSIX path of (folder of (path to me) as text)
end tell
assuming that you put the script you want to run in the folder "Users/lukas/Google Drive/006 semester/00_Bachelorarbeit/00_Documentation"

Related

electron-builder nsis run other executable during install

I'm trying to run a different executable during install of my app but I cannot find the right path to do it. The program is added with the following electron-builder config:
extraFiles:
- from: tools/tapinstall/${arch}/
to: resources/tapinstall/
filter:
- "**/*"
After installing my app I can see the files in the resources/tapinstall/ folder so it's being ported. Now, in my nsis installer.nsh I added an ExecWait directive to run an exe from that directory but it fails.
As a desperate measure I figured that prefixing everything with $INSTDIR was not the right move, maybe the path is not $INSTDIR and something else and I found 3 possible candidates:
$INSTDIR
$APPDATA
$BUILD_RESOURCES_DIR
I added this simple code to see which file gets created so I can figure out the right macro to use:
!macro customHeader
RequestExecutionLevel admin
!macroend
!macro customInstall
!system "echo 'as' > $INSTDIR/customInstall"
!system "echo 'bs' > $APPDATA/customInstall"
!system "echo 'cs' > $BUILD_RESOURCES_DIR/customInstall"
${ifNot} ${isUpdated}
!system "echo 'a' > $INSTDIR/customInstall"
!system "echo 'b' > $APPDATA/customInstall"
!system "echo 'c' > $BUILD_RESOURCES_DIR/customInstall"
${endIf}
!macroend
I then did a full search on my computer for a file called customInstall...nothing. What am I doing wrong?
!system (and all other ! instructions) are executed at compile-time inside makensis.exe. You cannot access variables/constants at compile time, only defines and environment variables.
!define foo "Hello"
!warning "${NSISDIR} & $%Temp% & ${foo}"
Var Bar
Section
StrCpy $Bar "World"
MessageBox mb_ok "$InstDir & $Bar"
SectionEnd

For loop in batch file dies calling Windows conversion tool

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"
)

Parsing NETSTAT -ban switches in batch

Extensive searches found no solution in batch to parse netstat -bano (same switch as -nab, -bna, -anb, -nba, nabo, etc.) so all info from a given network connection is on the same line.
Netstat's -ban switches are used to:
-b = display executable
-a = display all connections and listening ports
-n = display addresses and ports in numerical form.
-o = display owning process ID for each connection (i.e., PID)
But netstat adds the file name to the next line, making processing the output very difficult. Extensive searches didn't find any answers in batch.
I created a way to parse it by looking for a ] (right bracket) as the last character on a line. If it is a ], then basically output the "combined" line, which now contains the executable.
My code is posted as an answer, but does an ugly job since it has to use files to handle the parsing instead of variables.
The previous version of this script was missing a backslash. Additionally the script would delete the output file. Creating the file as %computername%--NETSTAT.txt instead of NETSTAT--%computername%.txt fixes the problem.
#ECHO OFF
SetLocal
REM Method of finding last character-of-a-string-from-a-variable
REM http://stackoverflow.com/a/15662607/1569434
REM Get the script's path so all needed files can sit in the same folder
SET SCRIPTPATH=%~p0
CD %SCRIPTPATH%
REM Read and pass each line in file one at a time to sub 'FindEXE'
SET CONCATLINE=
SET HEADERROW=
SET /A LINECOUNT = 0
#echo LINECOUNT = %LINECOUNT%
del %SCRIPTPATH%\netstat*.txt /q 2>nul
netstat -bano>%SCRIPTPATH%\netstat0.txt
REM Copy all lines except those with "TIME_WAIT" into text file
FINDSTR /V /I /C:"TIME_WAIT" %SCRIPTPATH%\netstat0.txt>%SCRIPTPATH%\netstat1.txt
REM Delete first two lines, which are a header and a blank line
for /f "skip=2 delims=*" %%a in (%SCRIPTPATH%\netstat1.txt) do (echo %%a>>%SCRIPTPATH%\netstat2.txt)
REM Search for and process file based on matching text
REM This sub begins putting each netstat connection on one line
for /f "delims=*" %%A in (%SCRIPTPATH%\netstat2.txt) do call :FindTXT1 %%A
REM netstat3 will have all data from given connection on one line
SET /A LINECOUNT = 0
for /f "delims=*" %%A in (%SCRIPTPATH%\netstat3.txt) do call :FindTXT2 %%A
REM Keep only header and unique (i.e., those with "[::]") 'listening' connections
FINDSTR /I /C:"LISTENING" /C:"Local Address" %SCRIPTPATH%\netstat4.txt>%SCRIPTPATH%\netstat5.txt
FINDSTR /I /C:"[::]:" /C:"Local Address" %SCRIPTPATH%\netstat5.txt>%SCRIPTPATH%\netstat6.txt
MOVE /Y %SCRIPTPATH%\netstat6.txt %SCRIPTPATH%\%computername%--NETSTAT.txt
del %SCRIPTPATH%\netstat*.txt /q 2>nul
#echo off
echo done.
EndLocal
goto :EOF
:FindTXT1
REM We've got a line sent to us. Set variable to entire line using * (instead of %1)
SET CURRENTLINE=%*
SET /A LINECOUNT = %LINECOUNT% + 1
REM Add line feed after header row and return to main script
IF "%LINECOUNT%" == "1" (
SET HEADERROW=%CURRENTLINE%
#ECHO %CURRENTLINE%> %SCRIPTPATH%\netstat3.txt
goto :eof
)
REM Append a comma and CURRENTLINE to CONCATLINE. NOTE: Script expecting comma; don't use semi-colon
SET CONCATLINE=%CONCATLINE%,%CURRENTLINE%
REM When echo line, remove first char (comma, inserted above) using:
REM http://ss64.com/nt/syntax-substring.html
REM If last char is "]" then print, otherwise append
IF "%CURRENTLINE:~-1%"=="]" (
REM #echo right bracket=FOUND
#echo %CONCATLINE:~1%>>%SCRIPTPATH%\netstat3.txt
SET CONCATLINE=
) else (
REM #echo right bracket=NOT found
)
REM If line = "Can not obtain ownership information" then print, otherwise append
IF "%CURRENTLINE%"=="Can not obtain ownership information" (
REM #echo No Ownership=TRUE
#echo %CONCATLINE:~1%>>%SCRIPTPATH%\netstat3.txt
SET CONCATLINE=
)
goto :eof
:FindTXT2
REM We've got a line sent to us. Set variable to entire line using * (instead of %1)
SET CURRENTLINE=%*
SET /A LINECOUNT = %LINECOUNT% + 1
REM Add line feed after header row and return to main script
IF "%LINECOUNT%" == "1" (
SET HEADERROW=%CURRENTLINE%
#ECHO %CURRENTLINE%> %SCRIPTPATH%\netstat4.txt
goto :eof
)
REM If last char is "]" then search, otherwise append.
REM Without "DelayedExp...", variable sets to value from previous FOR loop
IF "%CURRENTLINE:~-1%"=="]" (
SetLocal ENABLEDELAYEDEXPANSION
REM IP6 EXEs result in 3 sets of [], so find and set var to last one, which is where EXE lives
FOR /f "tokens=1,2,3,4,5,6 delims=[]" %%a in ("%CURRENTLINE%") do (
SET BINNAME1=%%b
SET BINNAME2=%%f
IF "!BINNAME1!" == "::" (
REM #ECHO BINNAME1=!BINNAME1!>>%SCRIPTPATH%\netstat4.txt
SET BINNAME=!BINNAME2!
REM #echo %CURRENTLINE%;BINNAME=!BINNAME2!>>%SCRIPTPATH%\netstat4.txt
) else (
SET BINNAME=!BINNAME1!
REM #echo %CURRENTLINE%;BINNAME=!BINNAME1!>>%SCRIPTPATH%\netstat4.txt
)
#echo %CURRENTLINE%;BINNAME=!BINNAME!>>%SCRIPTPATH%\netstat4.txt
)
) else (
#echo %CURRENTLINE%>>%SCRIPTPATH%\netstat4.txt
SetLocal DISABLEDELAYEDEXPANSION
)
goto :eof
Created solution in batch to concatenate all output for a given connection so it's on one line. Save script (below) as a batch file and when run it will create a file called "NETSTAT--%computername%.txt" in the same folder as the script, where %computername% will be replaced with the hostname of computer it's run on.
#ECHO OFF
SetLocal
REM Method of finding last character-of-a-string-from-a-variable
REM http://stackoverflow.com/a/15662607/1569434
REM Get the script's path so all needed files can sit in the same folder
SET SCRIPTPATH=%~p0
CD %SCRIPTPATH%
REM Read and pass each line in file one at a time to sub 'FindEXE'
SET CONCATLINE=
SET HEADERROW=
SET /A LINECOUNT = 0
#echo LINECOUNT = %LINECOUNT%
del %SCRIPTPATH%\netstat*.txt /q 2>nul
netstat -bano>%SCRIPTPATH%\netstat0.txt
REM Copy all lines except those with "TIME_WAIT" into text file
FINDSTR /V /I /C:"TIME_WAIT" %SCRIPTPATH%\netstat0.txt>%SCRIPTPATH%\netstat1.txt
REM Delete first two lines, which are a header and a blank line
for /f "skip=2 delims=*" %%a in (%SCRIPTPATH%\netstat1.txt) do (echo %%a>>%SCRIPTPATH%\netstat2.txt)
REM Search for and process file based on matching text
REM This sub begins putting each netstat connection on one line
for /f "delims=*" %%A in (%SCRIPTPATH%\netstat2.txt) do call :FindTXT1 %%A
REM netstat3 will have all data from given connection on one line
SET /A LINECOUNT = 0
for /f "delims=*" %%A in (%SCRIPTPATH%\netstat3.txt) do call :FindTXT2 %%A
REM Keep only header and unique (i.e., those with "[::]") 'listening' connections
FINDSTR /I /C:"LISTENING" /C:"Local Address" %SCRIPTPATH%\netstat4.TXT>%SCRIPTPATH%\netstat5.TXT
FINDSTR /I /C:"[::]:" /C:"Local Address" %SCRIPTPATH%\netstat5.TXT>%SCRIPTPATH%\netstat6.TXT
MOVE /Y %SCRIPTPATH%\netstat6.txt %SCRIPTPATH%\NETSTAT--%computername%.txt
del %SCRIPTPATH%netstat*.txt /q 2>nul
#echo off
echo done.
EndLocal
goto :EOF
:FindTXT1
REM We've got a line sent to us. Set variable to entire line using * (instead of %1)
SET CURRENTLINE=%*
SET /A LINECOUNT = %LINECOUNT% + 1
REM Add line feed after header row and return to main script
IF "%LINECOUNT%" == "1" (
SET HEADERROW=%CURRENTLINE%
#ECHO %CURRENTLINE%> %SCRIPTPATH%\netstat3.txt
goto :eof
)
REM Append a comma and CURRENTLINE to CONCATLINE. NOTE: Script expecting comma; don't use semi-colon
SET CONCATLINE=%CONCATLINE%,%CURRENTLINE%
REM When echo line, remove first char (comma, inserted above) using:
REM http://ss64.com/nt/syntax-substring.html
REM If last char is "]" then print, otherwise append
IF "%CURRENTLINE:~-1%"=="]" (
REM #echo right bracket=FOUND
#echo %CONCATLINE:~1%>>%SCRIPTPATH%\netstat3.txt
SET CONCATLINE=
) else (
REM #echo right bracket=NOT found
)
REM If line = "Can not obtain ownership information" then print, otherwise append
IF "%CURRENTLINE%"=="Can not obtain ownership information" (
REM #echo No Ownership=TRUE
#echo %CONCATLINE:~1%>>%SCRIPTPATH%\netstat3.txt
SET CONCATLINE=
)
goto :eof
:FindTXT2
REM We've got a line sent to us. Set variable to entire line using * (instead of %1)
SET CURRENTLINE=%*
SET /A LINECOUNT = %LINECOUNT% + 1
REM Add line feed after header row and return to main script
IF "%LINECOUNT%" == "1" (
SET HEADERROW=%CURRENTLINE%
#ECHO %CURRENTLINE%> %SCRIPTPATH%\netstat4.txt
goto :eof
)
REM If last char is "]" then search, otherwise append.
REM Without "DelayedExp...", variable sets to value from previous FOR loop
IF "%CURRENTLINE:~-1%"=="]" (
SetLocal ENABLEDELAYEDEXPANSION
REM IP6 EXEs result in 3 sets of [], so find and set var to last one, which is where EXE lives
FOR /f "tokens=1,2,3,4,5,6 delims=[]" %%a in ("%CURRENTLINE%") do (
SET BINNAME1=%%b
SET BINNAME2=%%f
IF "!BINNAME1!" == "::" (
REM #ECHO BINNAME1=!BINNAME1!>>%SCRIPTPATH%\netstat4.txt
SET BINNAME=!BINNAME2!
REM #echo %CURRENTLINE%;BINNAME=!BINNAME2!>>%SCRIPTPATH%\netstat4.txt
) else (
SET BINNAME=!BINNAME1!
REM #echo %CURRENTLINE%;BINNAME=!BINNAME1!>>%SCRIPTPATH%\netstat4.txt
)
#echo %CURRENTLINE%;BINNAME=!BINNAME!>>%SCRIPTPATH%\netstat4.txt
)
) else (
#echo %CURRENTLINE%>>%SCRIPTPATH%\netstat4.txt
SetLocal DISABLEDELAYEDEXPANSION
)
goto :eof

How to get relative path from current folder?

This is what i currently get with FOR loop:
FOR /R "ProgramFolder" %%P in (*) do (
echo %%P
)
C:\Folder\Folder2\ProgramFolder\Managed\bolt.dll
C:\Folder\Folder2\ProgramFolder\Resources\fmodstudio.dll
C:\Folder\Folder2\ProgramFolder\Plugins\dll\DynamicWaterNativeWrapper.dll
How to get pathes like this?
Managed\bolt.dll
Resources\fmodstudio.dll
Plugins\dll\DynamicWaterNativeWrapper.dll
edited on dbenham comments
#echo off
setlocal enableextensions disabledelayedexpansion
pushd c:\somewhere\ProgramFolder
for /f "tokens=1,* delims=\" %%a in (
'xcopy . "%temp%" /l /s'
) do if not "%%b"=="" echo(%%b
popd
The basic idea behind this code is to use the xcopy command not to copy, but to retrieve a list (/l) of the files that should be processed with relative paths. For it to work, it is necessary to first change the current active directory to the required one (pushd) and use a relative reference to the current folder (.)
The output of xcopy command with this configuration will be in the form
.\folder\folder\file.ext
To remove the prefixing dot and backslash the for /f is configured to use the slashes as delimiters and to retrieve the first token (the dot) before the first backslash and the rest of the line as the second token, that is, the relative paths
As the xcopy command output includes an aditional line with the total number of files, and this line will result in an aditional blank line in the output of the script, an aditional if is included to discard this line.

I can't send some command line parameters via Autohotkey to VLC

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""} "
}

Resources