python Library
OperateAllFiles
Keine Erläuterungen gefunden.
import os import glob #look for alls files with a specific extension fnames = glob.glob("./*.png") """ glob provides list of all files of specified type in path, windows double backslash are replaced by standart slash, rfind drops the orinal file extension, cmd may be any command line call """ debug = False w2d = "cropPDF" for i,f in enumerate(fnames): filename = f[0:f.rfind(".")].replace('\\', '/') if w2d=="rename": cmd = "mv "+filename+".png "+filename+"_"+'{0:1.4E}'.format(i)+".png" #or: os.rename(filename+".png", filename+"_"+'{0:1.4E}'.format(i)+".png") else w2d=="svg2pdf": outFile = filename + ".pdf" cmd = "inkscape --export-filename=" + outFile + " " + f else w2d=="cropPDF": cmd = "inkscape " + filename + ".svg --export-area-drawing --export-overwrite" #outFile = filename + "_cropped.pdf" #cmd = "inkscape --file=" + f + " --export-area-drawing --export-pdf=" + outFile + " --verb=FileClose" else w2d=="splitVideo": inputFile = f outputFile= f[0:f.rfind(".")]+"_%04d.png" cmd = "ffmpeg -i "+inputFile+" -r "+fps+" -vsync 0 "+outputFile else w2d=="png2video": fps=30 cmd = "ffmpeg -y -r "+fps+" -f image2 -s 1920x1080 " cmd = cmd + " -i "+f cmd = cmd + " -vcodec libx264 -crf 15 -pix_fmt yuv420p " cmd = cmd + "myVideo.mp4" if debug: print("debug:",cmd) else: os.system(cmd)
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.