DosTips.com

A Forum all about DOS Batch
It is currently 23 Nov 2017 10:55

All times are UTC-06:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 10 Jan 2017 04:20 
Offline

Joined: 10 Jan 2017 04:08
Posts: 2
Hi.

I am trying to adapt this batch file(made by adrian from wdtvforum.com) to work on folder/file names with spaces:

Quote:
FOR /F "delims=*" %%A IN ('dir /b /s *.mkv') DO CALL:WDTVFIX "%%A"
START "" logging.txt
GOTO :eof
:WDTVFIX
mkclean --optimize %~dpnx1 %~dpn1_fixed.mkv
if not errorlevel 0 (
ECHO Failed on %~nx1 remux! >> logging.txt
goto :eof)
ECHO OFF
if exist "%~dpn1_fixed.mkv" (
del "%~dpnx1"
ECHO Processing of %~nx1 successful! >> logging.txt
goto :eof


When using it, it works perfectly with D:\Test\test1.mkv, but does not work on D:\Test\test 1.mkv.

I am not in any way skilled in programming, so I hope someone can help me.

Thanks!
Gearer


Top
   
PostPosted: 10 Jan 2017 11:29 
Offline
Expert

Joined: 23 Jun 2013 06:15
Posts: 1441
Location: Germany
You only have to encapsulate any file (or directory) path in doublequotes and use command arguments/for variables with tilde (to avoid multiple encapsulation) to work with them without errors:

So the first lines should be changed to:
Code: Select all
FOR /F "delims=*" %%A IN ('dir /b /s "*.mkv"') DO CALL:WDTVFIX "%%~A"
START "" "logging.txt"
GOTO :eof
The other lines should be adjusted in the same way.

penpen.


Top
   
PostPosted: 10 Jan 2017 12:40 
Offline

Joined: 21 Mar 2014 08:50
Posts: 452
This is your problem:
Code: Select all
mkclean --optimize %~dpnx1 %~dpn1_fixed.mkv
fixed as:
Code: Select all
mkclean --optimize %1 "%~dpn1_fixed.mkv"


Top
   
PostPosted: 10 Jan 2017 13:37 
Offline

Joined: 10 Jan 2017 04:08
Posts: 2
Compo wrote:
This is your problem:
Code: Select all
mkclean --optimize %~dpnx1 %~dpn1_fixed.mkv
fixed as:
Code: Select all
mkclean --optimize %1 "%~dpn1_fixed.mkv"


This fixed the issue with spaces, but now the batch file does not continue to the next file. Also, the "delete old file" stopped working. Any ideas?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited