PC Review


Reply
Thread Tools Rate Thread

Batch File Merge

 
 
=?Utf-8?B?ZG91YmxlSg==?=
Guest
Posts: n/a
 
      12th Jun 2007
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
 
Reply With Quote
 
 
 
 
foxidrive
Guest
Posts: n/a
 
      13th Jun 2007
On Tue, 12 Jun 2007 14:23:01 -0700, doubleJ
<(E-Mail Removed)> wrote:

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

 
Reply With Quote
 
=?Utf-8?B?ZG91YmxlSg==?=
Guest
Posts: n/a
 
      13th Jun 2007
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

"foxidrive" wrote:

> Try mapping the server to a drive letter, or use
>
> pushd \\audioserver\audio1\tags\
> code
> popd
>
>
> which does it for you.

 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      13th Jun 2007
On Wed, 13 Jun 2007 07:10:02 -0700, doubleJ
<(E-Mail Removed)> wrote:

>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

 
Reply With Quote
 
Matthias Tacke
Guest
Posts: n/a
 
      13th Jun 2007
doubleJ wrote:
> 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

--
Greetings
Matthias
 
Reply With Quote
 
=?Utf-8?B?ZG91YmxlSg==?=
Guest
Posts: n/a
 
      13th Jun 2007
"Matthias Tacke" wrote:

> 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
>
> --
> Greetings
> Matthias


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
 
Reply With Quote
 
=?Utf-8?B?ZG91YmxlSg==?=
Guest
Posts: n/a
 
      13th Jun 2007
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
 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      14th Jun 2007
On Wed, 13 Jun 2007 14:43:01 -0700, doubleJ
<(E-Mail Removed)> wrote:

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

 
Reply With Quote
 
Matthias Tacke
Guest
Posts: n/a
 
      14th Jun 2007
doubleJ wrote:
> 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


--
Greetings
Matthias
 
Reply With Quote
 
=?Utf-8?B?ZG91YmxlSg==?=
Guest
Posts: n/a
 
      2nd Aug 2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
batch file call from a macro - how ? and required batch format VB-rookie Microsoft Excel Programming 3 5th Sep 2008 10:33 PM
How do you merge a 'reg' file using a batch file? Don J Windows XP Help 3 29th May 2007 02:38 PM
How to merge a "reg" file using a batch file? Don J Windows XP General 1 29th May 2007 03:05 AM
Save batch window msgs to a file from the batch prog Stephen Rainey Windows XP General 3 10th Jan 2007 12:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:31 AM.