Page 1 of 1

Reading from 3 files to create a command...

Posted: 13 Apr 2012 04:26
by phoenix_Rising
Hi guys,

In a similar vein to a previous query that i had i've got a situation where i need to read information from 3 files to build a command to be run...

The three files contain pathnames on different lines and i simply need a loop to call the whole line of data from each of the files and echo it out to the following command:

file1.txt = %var1%
file2.txt = %var2%
file3.txt = %var3%

each file has a the same amount of entries in it and i need to be able to loop through every line in them whilst using the data in the following command...

echo shntool split "%var1%" -f "%var2%" -m \-/-*-£-$-=-+-¬-`-¦-;-:-@-'-#-~- -t "%%p - %%t" -d "%DRIVE%\OJW\TEMP\%var3%"

The other problem i have is when trying to echo out the command is that the bit that reads "%%p - %%t" dosnt show up in the echo ...

Any ideas?

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 06:02
by Squashman
Like I posted in your last thread.
The very first set of code in this thread is what you would use.
viewtopic.php?f=3&t=3126

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 06:27
by foxidrive
If you describe how you create file1/2/3 then maybe other ideas can be used.

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 06:50
by Squashman
foxidrive wrote:If you describe how you create file1/2/3 then maybe other ideas can be used.

Kind of like your last post! :lol:

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 07:31
by foxidrive
:) maybe there is a simpler way.

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 08:20
by phoenix_Rising
Lol ... I'm 99% of the way there... although im sure this could be a LOT cleaner! :)

@echo off
setlocal EnableDelayedExpansion
dir /s /b c:\ojw\temp\ape\*.wav >c:\ojw\logs\APE_fullpath.txt
dir /s /b c:\ojw\temp\ape\*.cue >c:\ojw\logs\APE_cuefullpath.txt
dir /b c:\ojw\temp\ape >c:\ojw\logs\APE_albumfoldername.txt
3<c:\ojw\logs\APE_cuefullpath.txt 4<c:\ojw\logs\APE_albumfoldername.txt (
for /F "delims=" %%a in (c:\ojw\logs\APE_fullpath.txt) do (
set line=
set /P line=c:\ojw\tools\shntool.exe split "%%a" -f <&3
set /P line= ""!line!" -m \-/-*-£-$-=-+-¬-`-¦-;-:-@-'-#-~- -t "%%p - %%t" -d "c:\ojw\completed_album\ape\<&4
echo(!line!
)
) >c:\ojw\logs\diditwork.txt


Now....The reasen it's only 99% there and not 100% is this...

The above bit of code generates the following command for me:

c:\ojw\tools\shntool.exe split "c:\ojw\temp\ape\Anthrax (ape).rar\CDIMAGE.wav" -f "c:\ojw\temp\ape\Anthrax (ape).rar\CUE\B52 - FUNPLEX.cue" -m \-/-*-£-$-=-+-¬-`-¦-;-:-@-'-#-~- -t "%p - %t" -d "c:\ojw\completed_album\ape\Anthrax (ape).rar


The only problem is... It needs to be like this ...

c:\ojw\tools\shntool.exe split "c:\ojw\temp\ape\Anthrax (ape).rar\CDIMAGE.wav" -f "c:\ojw\temp\ape\Anthrax (ape).rar\CUE\B52 - FUNPLEX.cue" -m \-/-*-£-$-=-+-¬-`-¦-;-:-@-'-#-~- -t "%p - %t" -d "c:\ojw\completed_album\ape\Anthrax (ape).rar"

*** The only difference is the quote mark on the VERY end of the command!!! ***

I just cant seem to get it in there!! Everything i do IGNORES the quote at the end!

Ideas?

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 09:11
by foxidrive
Try this and see what is produced in testrun.bat.txt

Run it in c:\ojw\temp\ape\ folder

Code: Select all

@echo off 
del testrun.bat.txt 2>nul
for /f "delims=" %%a ('dir *.cue /b /s') do (
for /f "delims=" %%b ("%%~dpa\..") do (
echo c:\ojw\tools\shntool.exe split "%%~dpb\cdimage.wav" -f "%%a" -m \-/-*-£-$-=-+-¬-`-¦-;-:-@-'-#-~- -t "%%%%p - %%%%t" -d "%%~dpb">>testrun.bat.txt
)
)


This one might remove the entries files where a cdimage.wav doesn't exist.

Code: Select all

@echo off 
del testrun.bat.txt 2>nul
for /f "delims=" %%a ('dir *.cue /b /s') do (
for /f "delims=" %%b ("%%~dpa\..") do (
if exist "%%~dpb\cdimage.wav" (
echo c:\ojw\tools\shntool.exe split "%%~dpb\cdimage.wav" -f "%%a" -m \-/-*-£-$-=-+-¬-`-¦-;-:-@-'-#-~- -t "%%%%p - %%%%t" -d "%%~dpb">>testrun.bat.txt
)
)
)

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 10:17
by phoenix_Rising
I'll try it when i get home tonight!

Thanks Foxi... ;)

Re: Reading from 3 files to create a command...

Posted: 13 Apr 2012 18:13
by Aacini
phoenix_Rising wrote:*** The only difference is the quote mark on the VERY end of the command!!! ***

I just cant seem to get it in there!! Everything i do IGNORES the quote at the end!

Ideas?

Did you tried to change the ending

Code: Select all

echo(!line!
.. by this one?

Code: Select all

echo(!line!"

Re: Reading from 3 files to create a command...

Posted: 15 Apr 2012 02:38
by foxidrive
phoenix_Rising wrote:I'll try it when i get home tonight!

Thanks Foxi... ;)



Did it work?