Dr. Arne JachensDr. Arne Jachens

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

1CIEcolorCoordinates_Spectrum.py
2MatlabStructures.py
3ModelicaExecution.py
4ModelicaMatFilter.py
5OperateAllFiles.py
6dictionaryStatistics.py
7familienKonto.py
8makeDoc.py
9plotTimeSeries.py
10readData2DictOfArrays.py
11replaceInFile.py
12showPointOnCIExy.py
13testNumpyMatrix.py
14writeDictOfArrays.py
15writeTSV.py

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.