Skip to main content
Question

Shutdouwn Python Script : Move file from work directory to another directory

  • September 13, 2013
  • 3 replies
  • 12 views

farfar
Contributor
Forum|alt.badge.img+11
Hi all,

 

I need to move my Reader file (toto.shp.zip)  from its location to another directory after traitment. I think the best way to do it is into Shutdown python script. But i can't find the code to do it. Could some one to help me? 

 

 

Thanks an advance.

 

 

Farfar

3 replies

fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • September 13, 2013
Hi,

 

 

Another option would be to call a file copy reader in a second ws via the workspacerunner.

 

 

Hope this helps,

 

 

Itay

takashi
Supporter
  • September 14, 2013
Hi Farfar,

 

 

If you want to move the file with a Python script, os.rename function can be used:

 

-----

 

# Example import os   # target file name and source path file = 'toto.shp.zip' src = 'C:/tmp/src/' + file   # destination directory and dest. file path dir = 'C:/tmp/dest' dest = '%s/%s' % (dir, file)   if os.path.exists(src):     # if dest. file exists already, remove it.     # else if dest. directory does not exist, create it.     if os.path.exists(dest):         os.remove(dest)     elif not os.path.exists(dir):         os.makedirs(dir)          # rename (move) the source file     os.rename(src, dest)

 

-----

 

 

See more information about os module here:

 

15.1. os — Miscellaneous operating system interfaces

 

http://docs.python.org/2.7/library/os.html#module-os

 

 

Takashi

farfar
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • June 4, 2014
Hi All,

 

I need to retrieve a path of writer to remove this writer file from its directory to another one. i use Takashi example below but i couldn't retrive the writer path using Shutdown Python Script. 

 

 

Any idea?

 

Thanks an advance.

 

 

Farfar

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings