I'd like to list and index files (video files such as .mp4, .avi, ... in my case) in a directory
I used :
setlocal disableDelayedExpansion for /f "delims=" %%A in ('forfiles /s /m * /c "cmd /c echo @relpath"') do ( set "file=%%~A" setlocal enableDelayedExpansion echo !file:~2! endlocal )
But, this will only list files, and also include folder (i'd like the video files only). Exemple :
"script.bat" "video01.mp4" "video02.webm" "video03.avi" "exportfolder" "exportfolder\video04.avi" "exportfolder\video05.mpg"
I also don't want theses : "script.bat" and "exportfolder"
I know that if i put *.avi in the forfiles line, I won't have this probleme anymore, but i'll have to duplicate theses lines of script for eatch video format ... not very cool, right ?! It would be better if I exclude the directories and files I know I don't want to list, no ?
I think I have to put "/a-d" somewhere to hide directories, but where ?
But to hide the files I don't want to be listed and indexing the rest (give eatch of them a usable variables names and number), I have no clue ... perhapse somewhere near the "!file:~2!" line ?!
Anyway, let me show you what I'd like to have :
1. "video01.mp4" 2. "video02.webm" 3. "video03.avi" 4. "exportfolder\video04.avi" 5. "exportfolder\video05.mpg"
this would give the user of the script to pick a file of he's choice with something like :
set /p choice=What is the file you want to use ? if %choice%==1 set file=indexlist1 if %choice%==2 set file=indexlist2 if %choice%==3 set file=indexlist3 if %choice%==4 set file=indexlist4
and the script will proceed with the selected file ... if I manage to catch the value for the printed index file I want.
I hope you see what I'd like to do ?!
That's a lot of questions, know, but any help would be great !