I created the following .bat in order to copy a random .mp4 file from a directory A into a directory B (with a fixed file name video.mp4
). So, in the directory A there is a pool of .mp4 file, and in the directory B there is the the file video.mp4 (same name, but different video every time I execute my batch-file
).
That's a code who do this. It perfectly works.
@echo off
setlocal EnableDelayedExpansion
cd C:\Users\aless\Desktop\....DIRECTORY A
set n=0
for %%f in (*.*) do (
set /A n+=1
set "file[!n!]=%%f"
)
for /L %%i in (1,1,%time:~-1%) do set "dummy=!random!"
set /A "rand=(n*%random%)/32768+1"
copy "!file[%rand%]!" C:\Users\aless\Desktop\....DIRECTORY B\video.mp4
That's the question:
I want to add a file named "title.txt" (fixed name) in the directory B and I want that the original name of the .mp4 file chosen randomly will be written (before the copy action) into the content of the title.txt (without .mp4
extension).
So, at the end... every time I execute the .bat file, a random file have to be copied from directory A to directory B with a fixed file name (video.mp4) and the title.txt content have to be updated and substituted at the same time with the original file name without extensions.
How can I can add this operation in my code?
Thanks a lot
How can I do to add this feature to my code?