Batch File Merge

G

Guest

Hello...
I'm using COPY to cat 3 files together. I get this error using the script
below...

\\audioserver\audio1\tags\Copyright-128-44100-Mono.mp3
The system cannot find the path specified.
0 file(s) copied.
\\audioserver\audio1\tags\Copyright-128-44100-Mono.mp3
The system cannot find the path specified.
0 file(s) copied.

Of course, the file is there and the structure is correct. If I manually do
copy with all the file names it works just fine.
The script is as follows...

[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r \\Audioserver\Audio1\Mp3\Product-128-44100-Mono %%i in (.) do (
[4] copy /B
\\audioserver\audio1\tags\copyright-128-44100-mono.mp3+\\audioserver\audio1\mp3\product-128-44100-mono\%%i+\\audioserver\audio1\tags\wordsender-128-44100-mono.mp3 \\audioserver\audio1\mp3\product-128-44100-mono\merge\%%i
[5])
[6]goto :eof

Thanks, in advance...
JJ
 
F

foxidrive

I'm using COPY to cat 3 files together. I get this error using the script
below...

\\audioserver\audio1\tags\Copyright-128-44100-Mono.mp3
The system cannot find the path specified.
0 file(s) copied.
\\audioserver\audio1\tags\Copyright-128-44100-Mono.mp3
The system cannot find the path specified.
0 file(s) copied.

Of course, the file is there and the structure is correct. If I manually do
copy with all the file names it works just fine.
The script is as follows...

[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r \\Audioserver\Audio1\Mp3\Product-128-44100-Mono %%i in (.) do (
[4] copy /B
\\audioserver\audio1\tags\copyright-128-44100-mono.mp3+\\audioserver\audio1\mp3\product-128-44100-mono\%%i+\\audioserver\audio1\tags\wordsender-128-44100-mono.mp3 \\audioserver\audio1\mp3\product-128-44100-mono\merge\%%i
[5])
[6]goto :eof

Thanks, in advance...
JJ

Try mapping the server to a drive letter, or use

pushd \\audioserver\audio1\tags\
code
popd


which does it for you.
 
G

Guest

I didn't know about pushd/popd. That didn't resolve the issue, though. I
mapped and tried pushd/popd and came with the same error...

S:\Mp3>mp3.bat
s:\tags\Copyright-128-44100-Mono.mp3
The specified path is invalid.
0 file(s) copied.
s:\tags\Copyright-128-44100-Mono.mp3
The specified path is invalid.
0 file(s) copied.
S:\Mp3>

I think I might know what the problem is, though...
I just did another batch that echo'd %%i and it shows...

\\audioserver\audio1\mp3\product-128-44100-mono\.
\\audioserver\audio1\mp3\product-128-44100-mono\Merge\.

instead of blehblehbleh.mp3, which is what I was trying to do. What I need
is to make the variable the filenames within the directory, not the variable
the directory's path.
JJ
 
F

foxidrive

I didn't know about pushd/popd. That didn't resolve the issue, though. I
mapped and tried pushd/popd and came with the same error...

S:\Mp3>mp3.bat
s:\tags\Copyright-128-44100-Mono.mp3
The specified path is invalid.
0 file(s) copied.
s:\tags\Copyright-128-44100-Mono.mp3
The specified path is invalid.
0 file(s) copied.
S:\Mp3>

I think I might know what the problem is, though...
I just did another batch that echo'd %%i and it shows...

\\audioserver\audio1\mp3\product-128-44100-mono\.
\\audioserver\audio1\mp3\product-128-44100-mono\Merge\.

instead of blehblehbleh.mp3, which is what I was trying to do. What I need
is to make the variable the filenames within the directory, not the variable
the directory's path.
JJ

You can use %%~nxi or put the batch file in \\audioserver\audio1\ and try
something like this (untested):


[1]@echo off
[2]net use s: \\audioserver\audio1\
[3]for /f "delims=" %%i in ('dir Mp3\Product-128-44100-Mono\*.mp3 /b') do (
[4]copy /B
tags\copyright-128-44100-mono.mp3+mp3\product-128-44100-mono\%%i+tags\wordsender-128-44100-mono.mp3
mp3\product-128-44100-mono\merge\%%i
[5] )
[6]net use s: /d
 
M

Matthias Tacke

doubleJ said:
I didn't know about pushd/popd. That didn't resolve the issue, though. I
mapped and tried pushd/popd and came with the same error...

S:\Mp3>mp3.bat
s:\tags\Copyright-128-44100-Mono.mp3
The specified path is invalid.
0 file(s) copied.
s:\tags\Copyright-128-44100-Mono.mp3
The specified path is invalid.
0 file(s) copied.
S:\Mp3>

I think I might know what the problem is, though...
I just did another batch that echo'd %%i and it shows...

\\audioserver\audio1\mp3\product-128-44100-mono\.
\\audioserver\audio1\mp3\product-128-44100-mono\Merge\.

instead of blehblehbleh.mp3, which is what I was trying to do. What I need
is to make the variable the filenames within the directory, not the variable
the directory's path.

But this behaviour is as expected if you read the help of

for /?

It helps if you format the batch in a way which is better raedable.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off&setlocal enabledelayedexpansion
for /r \\Audioserver\Audio1\Mp3\Product-128-44100-Mono %%i in (.) do (
copy /B \\audioserver\audio1\tags\copyright-128-44100-mono.mp3 ^
+\\audioserver\audio1\mp3\product-128-44100-mono\%%i ^
+\\audioserver\audio1\tags\wordsender-128-44100-mono.mp3 ^
\\audioserver\audio1\mp3\product-128-44100-mono\merge\%%i
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

If you want to process all mp3 files in the folder
\\Audioserver\Audio1\Mp3\Product-128-44100-Mono
the /r option is wrong one

Pushd/popd create/delete a temporary drive when used with an uri.

This (untested) batch might do what you want:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off&setlocal enabledelayedexpansion
pushd \\audioserver\audio1
for %%i in (\Mp3\Product-128-44100-Mono\*.mp3) do (
copy /B \tags\copyright-128-44100-mono.mp3 ^
+ "%%~fi" ^
+ \tags\wordsender-128-44100-mono.mp3 ^
"\mp3\product-128-44100-mono\merge\%%~nxi")
popd
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HTH
 
G

Guest

Matthias Tacke said:
If you want to process all mp3 files in the folder
\\Audioserver\Audio1\Mp3\Product-128-44100-Mono
the /r option is wrong one

Pushd/popd create/delete a temporary drive when used with an uri.

This (untested) batch might do what you want:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off&setlocal enabledelayedexpansion
pushd \\audioserver\audio1
for %%i in (\Mp3\Product-128-44100-Mono\*.mp3) do (
copy /B \tags\copyright-128-44100-mono.mp3 ^
+ "%%~fi" ^
+ \tags\wordsender-128-44100-mono.mp3 ^
"\mp3\product-128-44100-mono\merge\%%~nxi")
popd
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HTH

Whoohoo...
This works. Some things have changed on my end, so I'll need to play around
with it some more, but for now it partially works.
JJ
 
G

Guest

Ok...
Here is the final code that I have. It works and does, pretty much, exactly
what I want. Thanks for letting me know about pushd/popd. I had not seen
those before this week.

[01]@echo off
[02]setlocal enabledelayedexpansion
[03]pushd \\audioserver\audio1
[04]for %%a in (\mp3\productdvdbatch\*.mp3) do (
[05] set yfn=%%~nxa
[06] for /f "tokens=1,2,3,4 delims=-" %%b in ("!yfn!") do (
[07] if "!yfn:~0,2!" == "01" (
[08] md \mp3\productdvdmerge\Singles
[09] copy /B
\tags\copyright-128-44100-mono.mp3+"%%a"+\tags\wordsender-128-44100-mono.mp3
"\mp3\productdvdmerge\Singles\%%c"
[10] )
[11] if not "!yfn:~0,2!" == "01" (
[12] md \mp3\productdvdmerge\%%c
[13] copy /B
\tags\copyright-128-44100-mono.mp3+"%%a"+\tags\wordsender-128-44100-mono.mp3
"\mp3\productdvdmerge\%%c\%%d-%%e"
[14] )
[15] )
[16])
[17]popd

My only annoyances are that I had to duplicate the md/copy commands for 01
files and then everything else. Of course, it tries to make the directories
over and over, but fails as it's already there.
If anyone wants to show me ways to make the code more effecient, I would be
interested to see your versions.

What the batch does is...
1: Queries a bunch of mp3s in a single directory
2: Splits the filenames up by "-"
3: Creates directories based on the 2nd "-"
4: Merges the mp3s with two other mp3s
5: Copies the new mp3s into the directory that was just created
6: Renames the new mp3s using everything after the 2nd "-" in the original
name

All in all, it is pretty cool. It took a good day of work to get it all
working.
JJ
 
F

foxidrive

Ok...
Here is the final code that I have. It works and does, pretty much, exactly
what I want. Thanks for letting me know about pushd/popd. I had not seen
those before this week.

[01]@echo off
[02]setlocal enabledelayedexpansion
[03]pushd \\audioserver\audio1
[04]for %%a in (\mp3\productdvdbatch\*.mp3) do (
[05] set yfn=%%~nxa
[06] for /f "tokens=1,2,3,4 delims=-" %%b in ("!yfn!") do (
[07] if "!yfn:~0,2!" == "01" (
[08] md \mp3\productdvdmerge\Singles
[09] copy /B
\tags\copyright-128-44100-mono.mp3+"%%a"+\tags\wordsender-128-44100-mono.mp3
"\mp3\productdvdmerge\Singles\%%c"
[10] )
[11] if not "!yfn:~0,2!" == "01" (
[12] md \mp3\productdvdmerge\%%c
[13] copy /B
\tags\copyright-128-44100-mono.mp3+"%%a"+\tags\wordsender-128-44100-mono.mp3
"\mp3\productdvdmerge\%%c\%%d-%%e"
[14] )
[15] )
[16])
[17]popd

My only annoyances are that I had to duplicate the md/copy commands for 01
files and then everything else. Of course, it tries to make the directories
over and over, but fails as it's already there.
If anyone wants to show me ways to make the code more effecient, I would be
interested to see your versions.

What the batch does is...
1: Queries a bunch of mp3s in a single directory
2: Splits the filenames up by "-"
3: Creates directories based on the 2nd "-"
4: Merges the mp3s with two other mp3s
5: Copies the new mp3s into the directory that was just created
6: Renames the new mp3s using everything after the 2nd "-" in the original
name

All in all, it is pretty cool. It took a good day of work to get it all
working.


This will eliminate the error messages regarding the folders
[08] md \mp3\productdvdmerge\Singles 2>nul
[12] md \mp3\productdvdmerge\%%c 2>nul

If you can post a filename with and without an "01" we can see what's
causing the difference.
 
M

Matthias Tacke

doubleJ said:
Ok...
Here is the final code that I have. It works and does, pretty much, exactly
what I want. Thanks for letting me know about pushd/popd. I had not seen
those before this week.
snip

My only annoyances are that I had to duplicate the md/copy commands for 01
files and then everything else. Of course, it tries to make the directories
over and over, but fails as it's already there.
If anyone wants to show me ways to make the code more effecient, I would be
interested to see your versions.

if has also an else and instead of suppressing error messages you could
test for the existence of a folder prior creating it. Instead of repeating
long path\filenames I prefer a self explaining variable name


@echo off
setlocal enabledelayedexpansion
pushd \\audioserver\audio1
set CopyR=\tags\copyright-128-44100-mono.mp3
set Trail=\tags\wordsender-128-44100-mono.mp3
if not exist \mp3\productdvdmerge\Singles ^
md \mp3\productdvdmerge\Singles

for %%a in (\mp3\productdvdbatch\*.mp3) do (
set yfn=%%~nxa
for /f "tokens=1-4 delims=-" %%b in ("!yfn!") do (
if "!yfn:~0,2!" == "01" (
copy /B %CopyR%+"%%a"+%Trail% "\mp3\productdvdmerge\Singles\%%c"
) else (
if not exist \mp3\productdvdmerge\%%c ^
md \mp3\productdvdmerge\%%c
copy /B %CopyR%+"%%a"+%Trail% "\mp3\productdvdmerge\%%c\%%d-%%e"
)
)
)
popd
 
G

Guest

I found an error in my batch, where it would truncate the resultant filename
if there were more than 3 hyphens. I fixed it, but the code is kind of ugly.
If you guys can show me a cleaner way, I'd appreciate it.
JJ

[01]@echo off
[02]setlocal enabledelayedexpansion
[03]pushd \\audioserver\audio1
[04]set intro=\tags\copyright-128-44100-mono.mp3
[05]set outro=\tags\wordsender-128-44100-mono.mp3
[06]for %%a in (\mp3\test\*.mp3) do (
[07] set yfn=%%~nxa
[08] for /f "tokens=1-7 delims=-" %%b in ("!yfn!") do (
[09] if "!yfn:~0,2!" == "01" (
[10] if not exist \mp3\productdvdmerge\Singles md
\mp3\productdvdmerge\Singles
[11] copy /B %intro%+"%%a"+%outro% "\mp3\productdvdmerge\Singles\%%c"
[12] ) else (
[13] if not exist \mp3\productdvdmerge\%%c md \mp3\productdvdmerge\%%c
[14] if !yfn! == %%b-%%c-%%d-%%e (
[15] copy /B %intro%+"%%a"+%outro% "\mp3\productdvdmerge\%%c\%%d-%%e"
[16] ) else if !yfn! == %%b-%%c-%%d-%%e-%%f (
[17] copy /B %intro%+"%%a"+%outro% "\mp3\productdvdmerge\%%c\%%d-%%e-%%f"
[18] ) else if !yfn! == %%b-%%c-%%d-%%e-%%f-%%g (
[19] copy /B %intro%+"%%a"+%outro%
"\mp3\productdvdmerge\%%c\%%d-%%e-%%f-%%g"
[20] ) else if !yfn! == %%b-%%c-%%d-%%e-%%f-%%g-%%h (
[21] copy /B %intro%+"%%a"+%outro%
"\mp3\productdvdmerge\%%c\%%d-%%e-%%f-%%g-%%h"
[22] )
[23] )
[24] )
[25])
[26]popd
 
F

foxidrive

I found an error in my batch, where it would truncate the resultant filename
if there were more than 3 hyphens. I fixed it, but the code is kind of ugly.
If you guys can show me a cleaner way, I'd appreciate it.
JJ

Something like this might work (untested):
[01]@echo off
[02]setlocal enabledelayedexpansion
[03]pushd \\audioserver\audio1
[04]set intro=\tags\copyright-128-44100-mono.mp3
[05]set outro=\tags\wordsender-128-44100-mono.mp3
[06]for %%a in (\mp3\test\*.mp3) do (
[07] set yfn=%%~nxa
[08] for /f "tokens=1-4* delims=-" %%b in ("!yfn!") do (
[09] if "!yfn:~0,2!" == "01" (
md \mp3\productdvdmerge\Singles\ 2>nul
[11] copy /B %intro%+"%%a"+%outro% "\mp3\productdvdmerge\Singles\%%c"
[12] ) else (
md \mp3\productdvdmerge\%%c\ 2>nul
copy /B %intro%+"%%a"+%outro% "\mp3\productdvdmerge\%%c\%%d%%e"
)))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top