Question

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

  • 13 September 2013
  • 3 replies
  • 3 views

Badge
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

Userlevel 4
Badge +13
Hi,

 

 

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

 

 

Hope this helps,

 

 

Itay
Userlevel 3
Badge +17
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
Badge
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

Reply