0

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 !

Thanks !

Guillaume.

1
  • This will quickly become unmanageable if there are lots of videos and the command prompt window starts scrolling like crazy. Can you state your actual problem? A batch file may not even be required to do what you really want, and maybe we can suggest better solutions. Also be sure to mention which version of Windows you are using.
    – Karan
    May 22, 2013 at 22:51

1 Answer 1

0

I'm running the script on windows 8 or 7 only ;)

And as for a huge number of videos or files that will make the windows cmd scrolling like crazy: this script is meant to bo used only inside my company, and only for a few users (mostly editors or cg editors). for exemple a warning in the script should suffice to alert the user to not run the script in a folder that contains a huge amount of files or videos.

But I agree, this "forefiles" cmd is very slow ... even in small folder (few files).

My actual problem is that for a single project, there can be multiple video files (due to client needs for exemple), and i wanted to give the ability to the user to choose in this package of videos, the one (or some ... but thats another question ... again) he needs to proceed, and then send it, for validation purpose for exemple, or even batch resizing, ... anything is possible ;)

I ask mysefl about softwares already devellopped, that can completely do the job ... but no exactly the way I want, and with a lot more clicks, more time and less direct control or less specific needs , to have the result the script will be able to deliver.

Yes I got myself into the principle of "time is money" thing ... sadly i'd say. ^^

So, knowing all that, is my idea something that can be done this way ?

For now, i'm testing the script, and I make it work by having a specific naming format for the input file, but i'd like to get rid of that ! :)

thanks, I hope I answered you right and you'll be able to put me on tracks !

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .