Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

Need help running a nested program call from Windows 10 .BAT file without "UNC paths are not supported" error

So here's my situation. I currently have the following directory structure on both: local hard drive D: and on mapped network drive Z:.

D:Audiomp3
             Artist 1 - Album 1
             Artist 1 - Album 2
             Artist 1 - Album 3
             Artist 2 - Album 1
             etc.

Likewise, I have my network share \Diskstationmusic mapped to Z:, hence:

Z:mp3
       Artist 1 - Album 1
       Artist 1 - Album 2
       Artist 1 - Album 3
       Artist 2 - Album 1
       etc.

I am currently using two command line applications running from within my .BAT file to perform audio gain changes on all my mp3 files in these folders and subfolders.

The first program I use is called sweep.exe. It basically allows me to "sweep" all of the files that meet my file search type, *.mp3, into another program and go recursively through every folder doing so.

The program being called to actually make the gain changes is mp3gain. My .BAT file that runs on the local D: drive looks like the following:

d:
del gainadjust_output.txt
cd Audio
cd mp3
sweep mp3gain /a /c /d 7 /q /f *.mp3 > d:gainadjust_output.txt

When double clicking the .BAT file that is running locally from drive D:, I get output like the following:

Entering directory: '220 Volt - (2014) Walking In Starlight'
220 Volt - (2014) Walking In Starlight - 01 - Walking In Starlight.mp3
220 Volt - (2014) Walking In Starlight - 02 - System Overload.mp3
220 Volt - (2014) Walking In Starlight - 03 - Broken Promises.mp3
220 Volt - (2014) Walking In Starlight - 04 - Alive.mp3
220 Volt - (2014) Walking In Starlight - 05 - Blind.mp3
220 Volt - (2014) Walking In Starlight - 06 - Stranded.mp3
220 Volt - (2014) Walking In Starlight - 07 - Get Me Out.mp3
220 Volt - (2014) Walking In Starlight - 08 - The Waiting.mp3
220 Volt - (2014) Walking In Starlight - 09 - Through The Wastelands.mp3
220 Volt - (2014) Walking In Starlight - 10 - Burning Heart.mp3
220 Volt - (2014) Walking In Starlight - 11 - Take A Good Look.mp3
220 Volt - (2014) Walking In Starlight - 12 - One Good Reason.mp3
220 Volt - (2014) Walking In Starlight - 13 - Guiding Light.mp3

No changes to 220 Volt - (2014) Walking In Starlight - 01 - Walking In Starlight.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 02 - System Overload.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 03 - Broken Promises.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 04 - Alive.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 05 - Blind.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 06 - Stranded.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 07 - Get Me Out.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 08 - The Waiting.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 09 - Through The Wastelands.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 10 - Burning Heart.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 11 - Take A Good Look.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 12 - One Good Reason.mp3 are necessary

No changes to 220 Volt - (2014) Walking In Starlight - 13 - Guiding Light.mp3 are necessary

Entering directory: '24 - 7 Spyz - (1991) This Is 24 - 7 Spyz'
24 - 7 Spyz - (1991) This Is 24 - 7 Spyz - 01 - Tick, Tick ,tick.mp3
24 - 7 Spyz - (1991) This Is 24 - 7 Spyz - 02 - Stuntman.mp3
24 - 7 Spyz - (1991) This Is 24 - 7 Spyz - 03 - My Desire.mp3
24 - 7 Spyz - (1991) This Is 24 - 7 Spyz - 04 - Peace & Love.mp3
24 - 7 Spyz - (1991) This Is 24 - 7 Spyz - 05 - Earthquake.mp3

So everything is running like a champ.

However, when I run the near same BAT file from the mapped drive Z: which looks like this:

z:
del gainadjust_output.txt
cd mp3
sweep mp3gain /a /c /d 7 /q /f *.mp3 > z:gainadjust_output.txt

The operation fails due to what appears to be the UNC issue I mentioned in the subject:

'\Diskstationmusicmp3'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
*.mp3
Can't open *.mp3 for reading

Entering directory: 'Constantine - (2013) Resign Due'
'\Diskstationmusicmp3Constantine - (2013) Resign Due'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
*.mp3
Can't open *.mp3 for reading

I've tried using pushd ~dp0 and popd to stick the current drive letter on the stack and use that as an alias in the BAT file, but that still seems to just use the UNC path \Diskstationmusic which causes the UNC error again.

I'm not certain if this issue is the use of the sweep.exe program causing Z: not to be used, or if this is strictly an issue with running the BAT file on a network drive.

If you feel there is a way to do the same thing sweep.exe is doing passing files to the mp3gain.exe which also gets around the UNC issue, I'd love to hear about it. Right now, I've torn out quite a bit of hair and gone cross-eyed from googling UNC path issues with BAT files, so any help would be much appreciated!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...