Reading from 3 files to create a command...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
phoenix_Rising
Posts: 38
Joined: 04 Apr 2012 03:11

Reading from 3 files to create a command...

#1 Post by phoenix_Rising » 13 Apr 2012 04:26

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?

Squashman
Expert
Posts: 3666
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 13 Apr 2012 06:02

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

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

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

#3 Post by foxidrive » 13 Apr 2012 06:27

If you describe how you create file1/2/3 then maybe other ideas can be used.

Squashman
Expert
Posts: 3666
Joined: 23 Dec 2011 13:59

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

#4 Post by Squashman » 13 Apr 2012 06:50

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:

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

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

#5 Post by foxidrive » 13 Apr 2012 07:31

:) maybe there is a simpler way.

phoenix_Rising
Posts: 38
Joined: 04 Apr 2012 03:11

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

#6 Post by phoenix_Rising » 13 Apr 2012 08:20

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?

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

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

#7 Post by foxidrive » 13 Apr 2012 09:11

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

phoenix_Rising
Posts: 38
Joined: 04 Apr 2012 03:11

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

#8 Post by phoenix_Rising » 13 Apr 2012 10:17

I'll try it when i get home tonight!

Thanks Foxi... ;)

Aacini
Expert
Posts: 1465
Joined: 06 Dec 2011 22:15
Location: México City, México

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

#9 Post by Aacini » 13 Apr 2012 18:13

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

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

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

#10 Post by foxidrive » 15 Apr 2012 02:38

phoenix_Rising wrote:I'll try it when i get home tonight!

Thanks Foxi... ;)



Did it work?

Post Reply