|
Answer» To preface, I have a folder named MOVIES that I store all of my movie files in. Within that folder are subfolders for each letter of the alphabet, the # sign (for movies that begin with a number or other non-alphabetic character), and a folder named MUSIC RELATED (for music related movies.)
I made the batchfile to by default, output a folder label, which is the letter of the alphabet that is the folder name, surrounded by dashes to make it very easy to see the next letter in the output file. I can also provide the argument /nolabels to output without the folder labels, but that's beside the point.
OUTPUT EXAMPLE:
- - - - - - - - - MUSIC RELATED - - - - - - - - VAN HALEN LIVE SHOWS <--- This is a sub-folder that contains what it is named. Only the folder name is output, not its contents) AC-DC - Let There Be Rock [1980].mp4 Mayor Of The Sunset Strip [2003].mp4 Mayor Of The Sunset Strip [2003].srt Searching For Sugar Man [2012].idx Searching For Sugar Man [2012].mp4 Searching For Sugar Man [2012].sub
- - - - - - - - # - - - - - - - - 2001 - A Space Odyssey [1968].mp4 2001 - A Space Odyssey [1968].srt The 40 Year Old Virgin (Unrated ) [2005].mp4 The 40 Year Old Virgin (Unrated ) [2005].srt
- - - - - - - - A - - - - - - - - A Street Cat Named Bob [2016].idx A Street Cat Named Bob [2016].mp4 A Street Cat Named Bob [2016].sub Airplane! [1980].mkv Airplane! [1980].srt
... Etc ...
I have a batchfile that adds the names of movies to a plain text file, of all the folders and movie files within the folder that the batchfile is run from. To make it clear, I have a folder full of movies with names such as the following:
EXAMPLE OUTPUT FROM EXISTING BATCHFILE:
- - - - - - - - - MUSIC RELATED - - - - - - - - VAN HALEN LIVE SHOWS AC-DC - Let There Be Rock [1980].mp4 Mayor Of The Sunset Strip [2003].mp4 Mayor Of The Sunset Strip [2003].srt Searching For Sugar Man [2012].idx Searching For Sugar Man [2012].mp4 Searching For Sugar Man [2012].sub
The batchfile works perfectly, except that ideally, I would like for the .srt, .idx, and .sub (files that contain the subtitles for each movie) to NOT be included in the resulting text file output.
EXAMPLE OUTPUT OF THE DESIRED MODIFIED NO SUBTITLES BATCHFILE:
- - - - - - - - - MUSIC RELATED - - - - - - - - VAN HALEN LIVE SHOWS AC-DC - Let There Be Rock [1980].mp4 Mayor Of The Sunset Strip [2003].mp4 Searching For Sugar Man [2012].mp4
Ideally, I would like to have the same batchfile do this, but if need be, I could run my existing batchfile, then run a different batchfile to process the output text file from the first to ACHIEVE my desired result.
I am not against using an external program, such as the awesome Notepad++, from within the batchfile to do some processing if need be. But if POSSIBLE, it would be great to not use anything but the batchfile itself, or themselves, to accomplish everything.
I don't know how to check each output line for a certain ending, and to not output that line if it finds a match to any of the following endings:
.idx .sub .srt
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PART 2
I would also like to add another argument named /noext that would output everything the same, but strip off the file extension part of each movie.
EXAMPLE OUTPUT WITH THE /noext ARGUMENT SPECIFIED:
- - - - - - - - - MUSIC RELATED - - - - - - - - VAN HALEN LIVE SHOWS AC-DC - Let There Be Rock [1980] Mayor Of The Sunset Strip [2003] Searching For Sugar Man [2012]
I think I know how to do everything except how to strip off the file extensions for this part.
Attached is my batchfile as-is.
Any help is greatly appreciated?
- ThaumTry using findstr; eg.
Code: [Select]dir "%%a"/OGN /B | findstr /v /i "\.srt$" | findstr /v /i "\.idx$" | findstr /v /i "\.sub$"
Edit: formatting; looks like markdown doesn't work on here?I did not know about FINDSTR. But even with your code, I am uncertain how to use it to omit outputting to the text file?The idea is to pipe the output from the dir command to findstr. By piping I mean direct the output of a command into another command by using the | symbol. Findstr can be used in multiple ways; it can exclude a text pattern, or it can show text based on the pattern. What I did there was exclude any lines that end with those extensions by chaining multiple calls to findstr, with each one excluding another extension. In order to use it, replace the dir command in the for loops you have in the batch file with something similar to what I posted.
Hope this helps.Thanks so much for taking the time to help.
Here is what I have to start with:
( echo - - LIST GENERATED: %DATE% - - FOR /F "delims=" %%a in ('dir /A:D /OGN /B') DO ( echo. echo - - - - - - - - %%a - - - - - - - - dir "%%a"/OGN /B ) )> MOVIE_LIST.TXT
I've tried multiple ways of replacing your code into mine, but can't get it to work.
Would you mind modifying what I have above with your example, since I can't seem to grasp it?Oh stupid me. I got it now and it works exactly as I wanted. THANKS!!!
Is there a way to edit and/or delete posts we make on here?
Now for part 2:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PART 2
I would also like to add another argument named /noext that would output everything the same, but strip off the file extension part of each movie.
EXAMPLE OUTPUT WITH THE /noext ARGUMENT SPECIFIED:
- - - - - - - - - MUSIC RELATED - - - - - - - - VAN HALEN LIVE SHOWS AC-DC - Let There Be Rock [1980] Mayor Of The Sunset Strip [2003] Searching For Sugar Man [2012]
I think I know how to do everything except how to strip off the file extensions for this part.
Attached is my newest updated version of the complete batchfile.
Quote from: carlos1001 on August 06, 2021, 04:58:54 PM Try using findstr; eg.
Code: [Select]dir "%%a"/OGN /B | findstr /v /i "\.srt$" | findstr /v /i "\.idx$" | findstr /v /i "\.sub$"
Edit: formatting; looks like markdown doesn't work on here?
This can be made more efficient by combining the three FINDSTR commands into one.
Code: [Select]dir "%%a"/OGN /B | findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$"
Quote from: Thaum2u on August 11, 2021, 02:42:47 AM I would also like to add another argument named /noext that would output everything the same, but strip off the file extension part of each movie.
Code: [Select]FOR /F "delims=" %%G IN ('dir "%%a"/OGN /B ^| findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$" /RIVC:"\.jpg$" /RIVC:"\.png$"') DO ECHO %%~nG
Quote from: Squashman on August 27, 2021, 09:01:23 AMThis can be made more efficient by combining the three FINDSTR commands into one.
Code: [Select]dir "%%a"/OGN /B | findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$"
Thanks!
Quote from: Squashman on August 27, 2021, 09:17:07 AM
Code: [Select]FOR /F "delims=" %%G IN ('dir "%%a"/OGN /B ^| findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$" /RIVC:"\.jpg$" /RIVC:"\.png$"') DO ECHO %%~nG
Thanks Squashman! I am not sure how to implement the code you suggested for me. The way I did it RESULTS in a blank file.
Here is my default routine (now updated with your more efficient code suggestions):
:DEFAULT ( echo - - LIST GENERATED: %DATE% - - FOR /F "delims=" %%a in ('dir /A:D /OGN /B') DO ( echo. echo - - - - - - - - %%a - - - - - - - - dir "%%a"/OGN /B | findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$" /RIVC:"\.jpg$" /RIVC:"\.png$" /RIVC:"\.bat$" ) )> %NAME%.TXT start notepad %NAME%.TXT
How would you modify that to omit file extensions in the resulting text file?My code:
Code: [Select]FOR /F "delims=" %%G IN ('dir "%%a"/OGN /B ^| findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$" /RIVC:"\.jpg$" /RIVC:"\.png$"') DO ECHO %%~nG replaces this code:
Code: [Select]dir "%%a"/OGN /B | findstr /RIVC:"\.srt$" /RIVC:"\.idx$" /RIVC:"\.sub$" /RIVC:"\.jpg$" /RIVC:"\.png$" /RIVC:"\.bat$" Could you please learn how to use CODE tags. It would be much appreciated.
Quote from: Squashman on September 01, 2021, 02:46:07 PMCould you please learn how to use CODE tags. It would be much appreciated.
You are awesome! Thank you so much! And now I know how to use the code tag as well.
|