Hi,
test.cmd
for /f "tokens=1,2 delims=." %I in ('dir /B/O:G *.mp4') do if EXIST %I del %I.mkv
>if EXIST jupe tututeen del jupe tututeen.mkv
The file is not erased even if I use quotes. "jupe tututeen.mkv"REgards,
JPD
file not erased
Re: file not erased
problems:
You post test.cmd
this suggests you refer to a batchfile.
Then you post code, not for a batchfile but for commandline.
Then you post a supposed result of your code that can not be the result of the code you posted.
The code you posted with the file "jupe tututeen.mkv" will result in an attempt to delete the file "jupe tututeen.mp4.mkv".
This delete will fail because this file does not exist.
You post test.cmd
this suggests you refer to a batchfile.
Then you post code, not for a batchfile but for commandline.
Then you post a supposed result of your code that can not be the result of the code you posted.
The code you posted with the file "jupe tututeen.mkv" will result in an attempt to delete the file "jupe tututeen.mp4.mkv".
This delete will fail because this file does not exist.
Re: file not erased
Robocopy.cmd
The batch has 77 lines
===================
On the command line:
C:\Users\PC\Videos\Movavi Library>for /f "tokens=1,2 delims=." %I in ('dir /B/O:G *.mp4') do if EXIST %I del /Q %I.mkv
C:\Users\PC\Videos\Movavi Library>if EXIST jupe tututeen DEL /Q jupe tututeen.mkv
C:\Users\PC\Videos\Movavi Library>echo %errorlevel%
0
The file is not deleted
Regards
JPD
Code: Select all
.........................
::
robocopy "C:\ZZ COURS" "D:\ZZ COURS" /S /FP /NJH /NS /NDL /XX /XO /R:2 /IT
PUSHD "C:\Users\PC\Videos\Movavi Library"
for /f "tokens=1,2 delims=." %I in ('dir /B/O:G *.mp4') do if EXIST %I del /Q %I.mkv
robocopy "C:\Users\PC\Videos\Movavi Library" "D:\MovaviScreenCaptureStudio" *.mp4 /FP /NJH /NS /NDL /XX /XO /R:2 /IT
::
PUSHD "C:\Users\PC\Videos\Movavi Screen Capture Studio"
for /f "tokens=1,2 delims=." %I in ('dir /B/O:G *.mp4') do if EXIST %I del /Q %I.mkv
::
.............................................
===================
On the command line:
C:\Users\PC\Videos\Movavi Library>for /f "tokens=1,2 delims=." %I in ('dir /B/O:G *.mp4') do if EXIST %I del /Q %I.mkv
C:\Users\PC\Videos\Movavi Library>if EXIST jupe tututeen DEL /Q jupe tututeen.mkv
C:\Users\PC\Videos\Movavi Library>echo %errorlevel%
0
The file is not deleted
Regards
JPD
Re: file not erased
Ok, I see what i have missed in your code.
You are using the "delims=." as an unreliable method to split the filename and the extension.
The dir selects the file "jupe tututeen.mp4".
The if exist might work but only if "jupe tututeen" exists as file or directory.
The del will fail because of the space in the filename.
Try
You are using the "delims=." as an unreliable method to split the filename and the extension.
The dir selects the file "jupe tututeen.mp4".
The if exist might work but only if "jupe tututeen" exists as file or directory.
The del will fail because of the space in the filename.
Try
Code: Select all
del /Q "%I.mkv"
Re: file not erased
Code: Select all
C:\Users\PC\Videos\Movavi Library>for /f "tokens=1,2 delims=." %I in ('dir /B/O:G *.mp4') do if EXIST %I del /Q "%I.mkv" && echo %errorlevel%
C:\Users\PC\Videos\Movavi Library>if EXIST jupe tututeen del /Q "jupe tututeen.mkv" && echo 0
C:\Users\PC\Videos\Movavi Library>dir
Le volume dans le lecteur C n’a pas de nom.
Le numéro de série du volume est 42F4-8985
Répertoire de C:\Users\PC\Videos\Movavi Library
2023-12-05 12:05 <DIR> .
2023-10-27 06:50 <DIR> ..
2023-10-27 06:51 73 721 216 jupe tututeen.mkv
2023-10-27 06:51 73 721 216 jupe tututeen.mp4
2 fichier(s) 147 442 432 octets
2 Rép(s) 153 911 738 368 octets libres
Re: file not erased
The dir shows your code is doing what you tell it to do.
There is no file or directory with the name "jupe tututeen" (filename without extension).
So the if returns false and the del is skipped.
There is no file or directory with the name "jupe tututeen" (filename without extension).
So the if returns false and the del is skipped.
Re: file not erased
Yes!
Thank you very much.
JPD
Thank you very much.
JPD
Re: file not erased
In batch file
Code: Select all
for /f "tokens=1,2 delims=." %%I in ('dir /B/O:G *.mp4') do if EXIST "%%I".mp4 del /Q "%%I".mkv