So there's this Python script in AvsPmod to batch create avs scripts from all the files inside a directory
It works great but the issue is that it names the avs with the extension of the file e.g myvideo.mkv.avs so when you encode it and mux it the resulting file will be named myvideo.mkv.mkv. I want the script to omit the extension, I know it's doable and probably simple but I don't know anything about Python since I'm not a programmer.Code:import os # Get the directory containing source files dirname = avsp.GetDirectory() if dirname: # Generate each of the avisynth scripts for filename in os.listdir(dirname): fullname = os.path.join(dirname, filename) if os.path.isfile(fullname): # Get the extension-based template string srctxt = avsp.GetSourceString(fullname) # Create the script string scripttxt = srctxt + '\n' + 'Sharpen(1.0)\nInfo()' # Write the script text to a file f = open(fullname + '.avs', 'w') f.write(scripttxt) f.close()
I encode hundreds of videos so removing the double extension is an annoying step that I want to remove from my workflow.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 6 of 6
Thread
-
-
actually,after the line (which pulls script by video name):
Code:srctxt = avsp.GetSourceString(fullname)
Code:fullname = os.path.join(dirname, os.path.splitext(fullname)[0])
Last edited by _Al_; 23rd Oct 2020 at 00:05.
-
Nope doesn't work, I tried this one and the first example befere your edit and neither worked.
Code:fullname = os.path.join(dirname, filename) fullname = os.path.join(dirname, os.path.splitext(fullname)[0])
Code:fullname = os.path.join(dirname, os.path.splitext(filename)[0])
srctxt = avsp.GetSourceString(fullname) is to get source filter e.g DirectShowSource or LWLibavVideoSource that you configured in AvsPmod so it needs to be included as far as I know.Last edited by pandachinoman; 23rd Oct 2020 at 00:25.
-
this should work, maybe there is a problem with indentation in your example, this below should be alright :
Code:import os # Get the directory containing source files dirname = avsp.GetDirectory() if dirname: # Generate each of the avisynth scripts for filename in os.listdir(dirname): fullname = os.path.join(dirname, filename) if os.path.isfile(fullname): # Get the extension-based template string srctxt = avsp.GetSourceString(fullname) # Create the script string scripttxt = srctxt + '\n' + 'Sharpen(1.0)\nInfo()' # Write the script text to a file f = open(os.path.splitext(fullname)[0] + '.avs', 'w') f.write(scripttxt) f.close()
-
Yeah that one worked, though AvsPmod was still giving me an indentation error with your example so I fixed it:
Code:import os # Get the directory containing source files dirname = avsp.GetDirectory() if dirname: # Generate each of the avisynth scripts for filename in os.listdir(dirname): fullname = os.path.join(dirname, filename) if os.path.isfile(fullname): # Get the extension-based template string srctxt = avsp.GetSourceString(fullname) # Create the script string scripttxt = srctxt + '\n' + 'Sharpen(1.0)\nInfo()' # Write the script text to a file f = open(os.path.join(dirname, os.path.splitext(fullname)[0]) + '.avs', 'w') f.write(scripttxt) f.close()
Similar Threads
-
Potplayer not playing AVS scripts
By Aludin in forum Software PlayingReplies: 3Last Post: 16th Apr 2019, 15:41 -
AVS scripts opened by VirtualDub but no video with AVFS
By abolibibelot in forum Video ConversionReplies: 24Last Post: 27th Nov 2018, 20:16 -
Creating AVS script in MeGui
By Manxsee in forum Video ConversionReplies: 2Last Post: 12th Jun 2018, 12:24 -
Encoding AVS scripts
By EHarlen in forum Newbie / General discussionsReplies: 2Last Post: 13th Feb 2018, 17:04 -
BATCH to create .avs files
By marcorocchini in forum Newbie / General discussionsReplies: 0Last Post: 9th Nov 2015, 10:00