Batch question on deleting!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

Re: Batch question on deleting!

#16 Post by phoenix_Rising » 10 Apr 2012 03:42

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!

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

Re: Batch question on deleting!

#17 Post by phoenix_Rising » 10 Apr 2012 14:01

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!

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

Re: Batch question on deleting!

#18 Post by Squashman » 10 Apr 2012 16:35

Take a look at this thread.
viewtopic.php?f=3&t=3126

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

Re: Batch question on deleting!

#19 Post by phoenix_Rising » 11 Apr 2012 08:29

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

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

Re: Batch question on deleting!

#20 Post by foxidrive » 11 Apr 2012 12:47

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


With this I get

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: Select all

@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?

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

Re: Batch question on deleting!

#21 Post by phoenix_Rising » 12 Apr 2012 06:56

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

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

Re: Batch question on deleting!

#22 Post by Squashman » 12 Apr 2012 07:17

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.

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

Re: Batch question on deleting!

#23 Post by phoenix_Rising » 12 Apr 2012 07:27

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

?

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

Re: Batch question on deleting!

#24 Post by foxidrive » 12 Apr 2012 08:33

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.

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

Re: Batch question on deleting!

#25 Post by phoenix_Rising » 12 Apr 2012 08:59

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!

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

Re: Batch question on deleting!

#26 Post by foxidrive » 12 Apr 2012 09:20

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: Select all

@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

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

Re: Batch question on deleting!

#27 Post by phoenix_Rising » 12 Apr 2012 09:48

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!

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

Re: Batch question on deleting!

#28 Post by Squashman » 12 Apr 2012 09:49

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.

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

Re: Batch question on deleting!

#29 Post by phoenix_Rising » 12 Apr 2012 14:07

Sure thing - Will do.

Thanks again..

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

Post Reply