User Tools

Site Tools


burim:python:script_change_file
  • script to read files and add two spcaces “ ”
import subprocess
var1 = "  "
var2 = ".txt"

subprocess.call(["ls -la -f *.* > temp.txt"],shell=True)
myfiles = open("temp.txt")
lines = myfiles.read().splitlines()

for i in lines:
  if "script_change.py" in i:
    print("I will not change %s " % i)
  else:
    myfile = open(i)
    newname = i + var2
    newfile = open(newname.lower(), "w") #dokuwiki needs to have the name only in lower case
    for j in myfile:
      newtext = var1 + j
      newfile.write(newtext)
burim/python/script_change_file.txt · Last modified: 2019/01/21 20:58 by burim

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki