View unanswered posts | View active topics It is currently 01 Sep 2014 14:59



Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Batch question on deleting! 
Author Message

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
Hey Foxidrive - I ammended the /b switch and it's looking good! I'm going to try some extensive testing this afternoon to see how it holds up but it looks really good! Thanks for all the help guys i really appreciate it.

I'll let you know how it goes this evening... I have a funny feeling i might have another one of these quetions rearing it's head!


10 Apr 2012 03:42
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
OK guys - Foxi's cracked it but i have a second condundrum! This may be easier?

I need to reference the text from two two text files and echo it to the screen.

for example:

test1.txt (has the following text in it)

This is the first text line
This is the second text line
This is the third text line

test2.txt (has the following text in it)

This is the first line of random text
This is the second line of random text
This is the third line of random text

I need to echo this out to the screen so i would get:

>This is the first text line this is the first line of random text

and then to loop through all the other lines , the next would be, you've guessed it...

>This is the second text line This is the second line of random text

i've tried variants using the "FOR /F" command referencing "delms" but nothings really working... I plan on using other text to build a command to be echo'd and run but need to have the lines of text assigned to variables that i can assign.

Any ideas? i've done similar things referencing 1 text file in my batch file bu struggling to use info from the two!


10 Apr 2012 14:01
Profile

Joined: 23 Dec 2011 13:59
Posts: 1802
Post Re: Batch question on deleting!
Take a look at this thread.
viewtopic.php?f=3&t=3126


10 Apr 2012 16:35
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
Ok the new problem is causing me all sorts of headache!

I have this piece of example code i've been using:

:MONKEYSDECOMPRESS
cls
@echo off
echo.
echo Now Decompressing APE...
echo.
DIR /B /S c:\OJW\TEMP\APE\*.ape >>c:\OJW\LOGS\MONKEYSPATH1.TXT
DIR /B c:\OJW\TEMP\APE >>c:\OJW\LOGS\MONKEYSPATH2.TXT
for /F "tokens=*" %%a IN (c:\OJW\LOGS\MONKEYSPATH1.TXT) DO set var1=%%a
for /F "tokens=*" %%b IN (c:\OJW\LOGS\MONKEYSPATH2.TXT) DO set var2=%%b
for /F "tokens=*" %%c IN (c:\OJW\LOGS\MONKEYSPATH1.TXT) DO echo c:\OJW\tools\mac.exe "%var1%" "c:\OJW\TEMP\APE\%var2%\CDIMAGE.wav" -d >>"c:\OJW\LOGS\APE_Decode_List.bat"
CALL "c:\OJW\LOGS\APE_Decode_List.bat"
pause
exit

Which works... But... for some reasen the for /f dosn't seem to read any further than the first line of text in both the .txt files (monkeyspath1.txt) & (monkeyspath2.txt) When it finishes decoding the first file i need it to move on to line 2 in the .txt files

Any ideas how i can get it to loop through?

Excuse the Newb code! im justing starting to work my way through it...


11 Apr 2012 08:29
Profile

Joined: 10 Feb 2012 02:20
Posts: 4114
Post Re: Batch question on deleting!
phoenix_Rising wrote:
I need to reference the text from two two text files and echo it to the screen.


With this I get

Quote:
This is the first text line - This is the first line of random text
This is the second text line - This is the second line of random text
This is the third text line - This is the third line of random text


Code:
@echo off
setlocal enabledelayedexpansion

< "file2.txt" (for /f "delims=" %%a in ('type "file1.txt"') do (
set var=
set /p "var="
if defined var echo %%a - !var!
)
)
pause



Does that help with your problem above?


11 Apr 2012 12:47
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
I just created a file1.txt and file2.txt with a few lines of text in each and ran the code from the same folder but i got:

"The System Cannot find the file specified."

Let me give you a little background as to why im trying to do this within my batch...

using the same files you have referenced in your example code:

file1.txt would be the full pathname and target file eg. (C:\music\ape\The_best_album_ever\CDIMAGE.ape)
file2.txt would be the name of the albums folder (The_best_album_ever)

Both files are sorted in such a way that there are exactly the same amount of entries in both files.
line 1 in file1.txt & file2.txt is the information necessary to process the command for album1

I'm really looking at a way of assigning a temporary variable to each line of data in both text files so i can echo out my command.

Eg. c:\tools\decompress.exe %var1% c:\completed_album\%var2%\CDIMAGE.wav -d

%var1% = The pathname
%var2% = The folder name

i can do that with the code i've written on the 2nd page of this thead... But for some reasen i just cant get it to loop through ALL the entries in both files...

Any ideas? Thanks for foxi for all your help so far!! (and everyone else.)


12 Apr 2012 06:56
Profile

Joined: 23 Dec 2011 13:59
Posts: 1802
Post Re: Batch question on deleting!
I know Foxi's code works. I did basically the same exact code when I posted the link for you to look at and was thinking maybe you could figure it out from the link I posted.

You may want to post the code you tried so we can see where it went wrong.


12 Apr 2012 07:17
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
Sorry my batch isnt that strong yet! :)

I've just worked it into my code and can see where i went wrong... its now outputting the data to screen... Any idea how i could refer to the variables when there needed within the command i plan on using in the post above?

Eg. c:\tools\decompress.exe %var1% c:\completed_album\%var2%\CDIMAGE.wav -d

%var1% = (file1.txt) The pathname
%var2% = (file2.txt) The folder name

?


12 Apr 2012 07:27
Profile

Joined: 10 Feb 2012 02:20
Posts: 4114
Post Re: Batch question on deleting!
phoenix_Rising wrote:
file1.txt would be the full pathname and target file eg. (C:\music\ape\The_best_album_ever\CDIMAGE.ape)
file2.txt would be the name of the albums folder (The_best_album_ever)



Why not describe your music library system of folders and what you want to do. Some of us have been there before and it could be less painless than asking questions about several tasks.


12 Apr 2012 08:33
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
Sure.

At this stage in the batch two DIR's are run and output to two files

DIR /B /S c:\OJW\TEMP\APE\*.ape >>c:\OJW\LOGS\MONKEYSPATH1.TXT
DIR /B c:\OJW\TEMP\APE >>c:\OJW\LOGS\MONKEYSPATH2.TXT

MONKEYSPATH1.TXT = Is a list of the FULL pathnames to the files that will be processed by monkeys audio decompressor
an example of an entry in this file would be "c:\OJW\TEMP\APE\Anthrax\Anthrax.ape"

MONKEYSPATH2.TXT = Is a list of JUST the folder that the album to be processed is in an example of an entry in this file would
be "Anthrax"

the batch then will run the following command with this information saved to variables to decompress ALL of the .ape file in the Monkeyspath1.txt

c:\OJW\tools\mac.exe "%var1%" "c:\OJW\Decompressed_Album\APE\%var2%\CDIMAGE.wav" -d

which within the example above would equate too:

c:\OJW\tools\mac.exe "c:\OJW\TEMP\APE\Anthrax\Anthrax.ape" "c:\OJW\Decompressed_Album\APE\anthrax\CDIMAGE.wav" -d

------------------------------------------------------------------------------------------------------------------------------------------------
So to confirm i want to run the following command:

c:\OJW\tools\mac.exe "%var1%" "c:\OJW\Decompressed_Album\APE\%var2%\CDIMAGE.wav" -d

Where %var1% is a line of data from Monkeyspath1.txt and %VAR2% is a line of data from Monkeyspath2.txt and for it to loop
through all lines in the files top to bottom in both.


I hope that makes a little more sense? If not just let me know!


12 Apr 2012 08:59
Profile

Joined: 10 Feb 2012 02:20
Posts: 4114
Post Re: Batch question on deleting!
ok... thanks

According to your command line, this batch file should process every .ape file and create cdimage.wav in the same folder as the .ape file.

Will there ever be more than one .ape file in a folder? You can replace cdimage.wav with %%~na.wav and it will create anthrax.wav from an anthrax.ape file.


Code:
@echo off
for /f "delims=" %%a in ('DIR /B /S "c:\OJW\TEMP\APE\*.ape" ') do "c:\OJW\tools\mac.exe" "%%a" "%%~dpa\CDIMAGE.wav" -d


12 Apr 2012 09:20
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
That is beautifully simpler!

Just stuck that in and it works like a charm! Thanks so much guys!

I'm sure it's not the last hurdle but thanks so much or the help on this!


12 Apr 2012 09:48
Profile

Joined: 23 Dec 2011 13:59
Posts: 1802
Post Re: Batch question on deleting!
Please start a new thread if you have anything else. I think we have covered about 3 different questions in this thread already that didn't even relate to the original Thread Title.


12 Apr 2012 09:49
Profile

Joined: 04 Apr 2012 03:11
Posts: 38
Post Re: Batch question on deleting!
Sure thing - Will do.

Thanks again..

Stay posted, im sure i'll hit another conundrum in a day or so! :)


12 Apr 2012 14:07
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.