Author Topic: Hot folder script  (Read 217 times)

ScripterBoy

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
  • Scribus User
Hot folder script
« on: September 07, 2018, 03:22:11 pm »
Is it possible to create a Scribus script to be "hearing" a folder and when a file arrives into it, then start a text import process?.

I have been trying to implement a directory listing but python commands like os.listdir('.'): seems that does not work.

Thank you so much for your help.

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1620
  • Karma: 23
    • the graphics lab
Re: Hot folder script
« Reply #1 on: September 07, 2018, 03:57:28 pm »
yes, it's very likely that there are ways to do that with python.

i've not done it yet, but it must be possible...

... just one question: what are the signs, of os.listdir('.') not working?
here it does what it is supposed to...

ciao
a.l.e

ScripterBoy

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
  • Scribus User
Re: Hot folder script
« Reply #2 on: September 07, 2018, 06:20:27 pm »
As you can see, this is just a simple code for getting current directory contents, and then put this contents into a textframe called c1.

openDoc("c:/users/one/Desktop/tt.sla")
cad=''
for x in os.listdir('.'):
   cad=cad+x

insertText(cad,0,"c1")

But what I get on console, when I try running this is

NameError: name 'os' is not defined

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1620
  • Karma: 23
    • the graphics lab
Re: Hot folder script
« Reply #3 on: September 07, 2018, 06:36:47 pm »
well, you have to first

import os

before using it...

ScripterBoy

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
  • Scribus User
Re: Hot folder script
« Reply #4 on: September 07, 2018, 08:12:07 pm »
My apologies,

I´m not yet familiar enought with Python.

I´m gonna try to do a loop over the "scanned" directory and then, depending on what kind of file I will dectec arriving on it, I would like to launch another script from the loop, is it possible?

I´m sorry for my (big) mistake and thank you so much for your time.