Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th May 2020, 16:52   #61  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Nah, Im continuing to use older avs+ header, minus the stdint header requirement which prevents VS2008 compiler use.
No problems.

EDIT: Above for v2.6/2.6+ plugs, am still using 2.5 header for avs 25 plugs.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 9th May 2020 at 17:02.
StainlessS is offline   Reply With Quote
Old 2nd November 2022, 01:01   #62  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Feature request: loop through files inside a folder. Recurse into subdirectories if needed.

Purpose: avoid hardcoding of paths in scripts.
flossy_cake is offline   Reply With Quote
Old 2nd November 2022, 05:13   #63  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Code:
RT_WriteFileList(String,String,bool "append"=false)
 Non-clip function.
 This function, takes as the first string, a filename template with wildcards, this template can be eg
 "Fred.jpg" or "Fr?d.jp*g". where the '?' character matches any single character and the '*' wildcard matches zero or more characters.
 v1.03, Can take multiple pipe ('|') separated Wilcards in the extension ONLY, as in "D:\Pics\*.BMP|JP*G|PNG"
 The second string is the output filename which will be created and contain the files matching the input file template.
 The function will return the number of filenames written into the output file. Directories are ignored altogether
 and not written to the output file. A return of -1 indicates a problem opening/writing the output file.
 v1.06, Append, if true appends to existing file. NOTE, the return value does NOT include any already existing
 filenames if append is true (use RT_FileQueryLines to inquire total number of filenames when append = true).
It dont cope with directories (ignored - one day I might do same to fetch a list of folder names so you can scan on those too).

Do search on "RT_WriteFileList", one script using it here:-
https://forum.doom9.org/showthread.p...73#post1916173

EDIT: Smaller script function here:- https://forum.doom9.org/showthread.p...35#post1914335

EDIT: nuther one:- https://forum.doom9.org/showthread.p...10#post1911810

EDIT: Yet a nuther 1:- https://forum.doom9.org/showthread.p...st#post1896023
I accidentally deleted some files, and recovered some 1000's of text files all with names like asaoidajljlasa.txt,
is really tedious having to look though 10,000 text files so i made a script that showed any files containing a particular word on
a video clip frame. Much easier just moving to next frame instead of loading another text file into a text editor.
Quote:
# ShowTextFiles.avs
/*
Req RT_Stats, v1.43+, Grunt.

Scan directory of text files, showing first few lines of each file on frame [original intent to aid recovery of accidentally deleted text files from 10,000 possible recovered txt files].
Outputs list of Files with SearchWord found to DebugView, even when DEBUG=False
*/
EDIT:
You could also perhaps find use for this,
Code:
RT_FSelOpen(string "title"="Open",string "dir"="",string  "filt",string "fn="",bool "multi"=false,bool "debug"=false)

 Function to select EXISTING filename using GUI FileSelector.

 Title = Title bar text.
 Dir   = Directory, "" = Current
 Filt  = Lots, eg "All Files (*.*)|*.*"
         [Displayed text | wildcard] [| more pairs of Displayed text and wildcard, in pairs ONLY].
         first one is default.
 fn    = Initially presented filename (if any).
 multi = Multiply Select filenames. Allows selection of more than one filename at once.
 debug = Send error info to DebugView window.

 Returns
   int, 0, user CANCELLED.
   int, non zero is error (error sent to DebugView window).
   String, Filename selected, Chr(10) separated multiline string if MULTI==true (and multiple files selected).

   Example, to prompt for an AVI file and play it.
    avi=RT_FSelOpen("I MUST have an AVI",filt="Avi files|*.avi")
    Assert(avi.IsString,"RT_FSelOpen: Error="+String(avi))
    AviSource(avi)

From the source code before it was included into RT_Stats, here:- https://forum.doom9.org/showthread.p...07#post1638307
Code:
AVSValue __cdecl  FSelOpen(AVSValue args, void* user_data, IScriptEnvironment* env) {
    char * myName="FSelOpen: ";
    const char * myFilter=
        "All files (*.*)|*.*|"
        "Avi Files (*.avi;*.XVid;*.DivX)|*.avi;*.XVid;*.DivX|"
        "Mpg files (*.vob;*.mpg;*.mpeg;*.m1v;*.m2v;*.mpv;*.tp;*.ts;*.trp;*.m2t;*.m2ts;*.pva;*.vro)|*.vob;*.mpg;*.mpeg;*.m1v;"
        "*.m2v;*.mpv;*.tp;*.ts;*.trp;*.m2t;*.m2ts;*.pva;*.vro|"
        "Other Vid (*.mkv;*.Wmv;*.mp4;*.flv;*.ram;*.rm)|*.mkv;*.Wmv;*.mp4;*.flv;*.ram;*.rm|"
        "Audio Files (*.mp3;*.mpa;*mp1;*.mp2;*.wav)|*.mp3;*.mpa;*mp1;*.mp2;*.wav|"
        "Avs files (*.avs;*.avsi)|*.avs;*.avsi|"
        "Text files (*.txt;*.log;*.asc)|*.txt;*.log;*.asc|"
        "Image files (*.bmp;*.jpg;*.jpe;*.jpeg;*.png;*.tga;*.tif;*.gif;*.tiff)|*.bmp;*.jpg;*.jpe;*.jpeg;*.png;*.tga;*.tif;*.gif;*.tiff|"
        "Bat files (*.bat)|*.bat|";
        "Exe files (*.exe)|*.cmd";
Note the choice of wildcards allowed.
Quote:
Originally Posted by StainlessS View Post
EDIT: For those that like to watch a movie and read scrolling text at the same time. Requires RT_Stats v1.20.
Code:
avi = FSelOpen("Select an AVI",Filt="*.AVI|*.AVI")
Assert(avi.IsString,"FSelOpen: Error="+String(avi))
AVISource(AVI)
txt = FSelOpen("Select a Text file",Filt="*.txt|*.txt")
Assert(txt.IsString,"FSelOpen: Error="+String(txt))
Txt=RT_ReadTxtFromFile(txt)
Return ScriptClip("""RT_Subtitle("%s",Txt,align=2,y=height+100-current_frame,expy=true)""") # Requires RT_Stats v1.20
Prompts for AVI file, then for a Txt file

EDIT: FSelOpen, will only allow selecting existing files. FSelSaveAs, prompts for Overwrite if existing selected.
The is also FSelFolder() which prompts for exising folder name. [perhaps I should allow it to return multiple folder names <as Chr(10) separated string>].
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 2nd November 2022 at 05:48.
StainlessS is offline   Reply With Quote
Old 2nd November 2022, 11:15   #64  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 605
Wow ok, wasn't expecting that.

I suppose I should probably explain what I'm trying to do.

Basically I want to iterate through all the files inside a dir (and its subdirs) and check if a filename matches the one I'm looking for.

In the meantime I'm working around it by using an ahk script to generate my avs scripts programatically so I can get away with having hardcoded paths for now. It's still a little annoying though as it means if I ever moved the avs files (or the video files they point to) to another location then the whole thing breaks (but, I can just run the ahk scripts again so it's not the total end of the world but still would be nice to have completely self-contained, self-sufficient avs scripts with no external path dependencies).
flossy_cake is offline   Reply With Quote
Old 2nd November 2022, 16:46   #65  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
check if a filename matches the one I'm looking for.
Well I'm not aware of anything that allows you to examine folder names,
There is Exist("filename") :- http://avisynth.nl/index.php/Internal_functions#Exist
which works also on folder name so long as it does NOT end in slash/backslash
(although I've a feeling that Pinterf fixed that in current AVS+).

You could also scan a RT_WriteFileList to see if matching file exists but Exist() quicker.

Avisynthesizer_Mod has a Batch mode which creates avs script for each {possibly mulitple} GUI selected file, using a script template.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 2nd November 2022 at 16:49.
StainlessS is offline   Reply With Quote
Old 2nd November 2022, 21:10   #66  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 996
Quote:
Originally Posted by flossy_cake View Post
Feature request: loop through files inside a folder. Recurse into subdirectories if needed.

Purpose: avoid hardcoding of paths in scripts.
When I move a video file, I also move the associated avs file. Or I can copy the avs file somewhere else.
So for me this works quite well. Hibrydcoding
Code:
SourceFile = ScriptDir() + "Hammer.mkv"
SourceFile = Exist(SourceFile) ? SourceFile : "E:\Ablage\Hammer.mkv"
video=LWLibavVideoSource(SourceFile, cache=False)
audio=LWLibavAudioSource(SourceFile, cache=False)
audioDub(video, audio)
__________________
Live and let live
gispos is offline   Reply With Quote
Reply

Tags
for-loop, if-then-else, while-loop

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:31.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.