Assigning Shortcut Key to Make List of Videos Play, Batch File to Get Filename and Add TXT File, and Call System Default Player to Run Video with Attribute
In this article, we will discuss how to create a batch file that can be used to make a list of videos play automatically. This can be done by assigning a shortcut key to the batch file and using a text file to store the list of video files. We will also cover how to call the system default player to run the videos with the necessary attributes.
Creating the Batch File
The first step is to create a batch file that will be used to run the videos. This can be done by opening a new text document and saving it with the extension .bat. For example, you could name the file "play\_videos.bat".
Once the batch file has been created, you can add the following code to it:
@echo off
setlocal enabledelayedexpansion
set "video\_list=videos.txt"
for /f "delims=" %%a in (%video\_list%) do (
set "filename=%%a"
start /wait "" "!filename!"
)
This code will read the list of video files from the "videos.txt" file and run each video one after the other. The /wait option is used to ensure that the next video in the list is not started until the current video has finished playing.
Creating the Shortcut Key
To create a shortcut key for the batch file, you can use the following steps:
- Right-click on the desktop and select "New" > "Shortcut".
- In the "Create Shortcut" dialog box, enter the path to the batch file in the "Type the location of the item" field. For example, you could enter "
C:\path\to\play\_videos.bat". - Click "Next" and enter a name for the shortcut in the "Type a name for this shortcut" field. For example, you could enter "Play Videos".
- Click "Finish" to create the shortcut.
- Right-click on the shortcut and select "Properties".
- In the "Shortcut" tab, click in the "Shortcut key" field and press the key combination that you want to use as the shortcut key. For example, you could use "Ctrl+Alt+P".
- Click "OK" to save the changes.
Creating the List of Videos
To create the list of videos, you can use a text editor to create a new file called "videos.txt". You can then add the names of the video files to this file, one per line. For example:
video1.mp4
video2.mp4
video3.mp4
Calling the System Default Player
To call the system default player to run the videos, you can use the following code in the batch file:
@echo off
start /wait "" "%1"
This code will start the first video in the list using the system default player. The "%1" parameter is used to pass the name of the video file as an argument to the batch file. This allows the batch file to be used to run any video file, not just those in the list.
Adding Attributes
To add attributes to the video player, you can use the following code:
start /wait "" "%1" /fullscreen /max
This code will start the video player in fullscreen mode with the window maximized. You can replace "fullscreen" and "max" with any other valid attributes that are supported by the video player.
- Create a batch file called "play\_videos.bat" with the code to read the list of video files and run them one after the other.
- Create a shortcut to the batch file and assign a shortcut key to it.
- Create a text file called "videos.txt" with the list of video files.
- Modify the batch file to call the system default player and pass the name of the video file as an argument.
- Add any necessary attributes to the video player in the batch file.