简体   繁体   中英

File conversion and deletion on Windows

I've got some 90 000 .m4a audio recordings, all grouped in various sub-folders depending on their purpose. I want to convert each one to .wav and then delete the original .m4a after successful conversion. For reasons beyond my control I'm doing this on a Windows machine with limited capacity. I need to delete as I go along, because I don't have the space to keep both versions.

I have the locations of all files stored, and can easily generate a batch file to do conversion and deletion using ffmpeg and DEL iteratively (which is a solution I've seen suggested in several places). But is there a way to check that the conversion has been successful before deleting? I really don't fancy losing the data by accident.

It's not a perfect check to make sure everything worked, but you can use something like this to make sure the target file exists and contains at least a few bytes:

@echo off
setlocal

rem configuration values, toconvert should probably come from %1
set toconvert=source file.mp3
set minsize=100
for %%a in ("%toconvert%") do (
    set target=%%~da%%~pa%%~na.wav
)

rem replace with a real call to ffmpeg
echo call ffmpeg -i "%toconvert%" "%target%"

set size=0
if exist "%target%" (
    for %%a in ("%target%") do (
        set size=%%~za
    )
)

if %size% LSS %minsize% (
    echo ERROR: The file is too small!
) ELSE (
    rem replace with a real call to del
    echo del "%toconvert%"
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM