Create File Folder with Syntax

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Create File Folder with Syntax

Egon Kraan
I was just wondering if it was possible to create a directory file folder
using syntax and then save the output file in it?

Egon Kraan
Research Analyst
TNS NFO
600 Vine Street, Suite 300
Cincinnati, Ohio 45202

Phone:   (513) 345-6735
Fax:       (513) 461-7989
Email:    [hidden email]
Web:      www.tns-global.com
----------------------------------------------------------------------------
------------
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the addressee or authorized to receive this for the
addressee,
you must not use, copy, disclose or take any action based on this message
or any information herein. If you have received this message in error,
please advise the sender immediately by reply e-mail and delete this
message. Thank you for your cooperation.
----------------------------------------------------------------------------
------------
Reply | Threaded
Open this post in threaded view
|

AW: Create File Folder with Syntax

la volta statistics
Try the following syntax.

HOST COMMAND=['IF not exist d:\TryIt    MD d:\TryIt'].

So long, Christian

-----Ursprüngliche Nachricht-----
Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von
Egon Kraan
Gesendet: Mittwoch, 18. Oktober 2006 16:21
An: [hidden email]
Betreff: Create File Folder with Syntax


I was just wondering if it was possible to create a directory file folder
using syntax and then save the output file in it?

Egon Kraan
Research Analyst
TNS NFO
600 Vine Street, Suite 300
Cincinnati, Ohio 45202

Phone:   (513) 345-6735
Fax:       (513) 461-7989
Email:    [hidden email]
Web:      www.tns-global.com
----------------------------------------------------------------------------
------------
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the addressee or authorized to receive this for the
addressee,
you must not use, copy, disclose or take any action based on this message
or any information herein. If you have received this message in error,
please advise the sender immediately by reply e-mail and delete this
message. Thank you for your cooperation.
----------------------------------------------------------------------------
------------
Reply | Threaded
Open this post in threaded view
|

Re: Create File Folder with Syntax

Peck, Jon
In reply to this post by Egon Kraan
You have seen how to use HOST to create the directory.  In order to save the output file at a given point in your job via syntax, there are two choices.

If you have SPSS 15, use the new OUTPUT SAVE command.
If you have SPSS 14 and programmability, use the viewer module SaveDesignatedOutput() method.

You can also handle the save with the SPSS Production Mode application.

You can do a save with a SaxBasic function, but it is difficult to synchronize that with your syntax stream.

If you can use the OMS output, you can save selected output that way and bypass the Viewer document altogether.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Egon Kraan
Sent: Wednesday, October 18, 2006 9:21 AM
To: [hidden email]
Subject: [SPSSX-L] Create File Folder with Syntax

I was just wondering if it was possible to create a directory file folder
using syntax and then save the output file in it?

Egon Kraan
Research Analyst
TNS NFO
600 Vine Street, Suite 300
Cincinnati, Ohio 45202

Phone:   (513) 345-6735
Fax:       (513) 461-7989
Email:    [hidden email]
Web:      www.tns-global.com
----------------------------------------------------------------------------
------------
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the addressee or authorized to receive this for the
addressee,
you must not use, copy, disclose or take any action based on this message
or any information herein. If you have received this message in error,
please advise the sender immediately by reply e-mail and delete this
message. Thank you for your cooperation.
----------------------------------------------------------------------------
------------
Reply | Threaded
Open this post in threaded view
|

Re: Create File Folder with Syntax

King Douglas
If you have SPSS 14 or 15 and Python, you can create new directories from inside SPSS by invoking the os module.  The following will create a new directory "makedir" given that the "TEMP" directory already exists.

  BEGIN PROGRAM.
  import os
  os.mkdir("C:\TEMP\\makedir")
  END PROGRAM.

  If the "TEMP" directory does not already exist, you can create both the parent and the child directories in one statement (note differences in function call and path delimiters):

  BEGIN PROGRAM.
  import os
  os.makedirs("C:\\TEMP\\makedir")
  END PROGRAM.

  King Douglas
  American Airlines Customer Research

"Peck, Jon" <[hidden email]> wrote:
  You have seen how to use HOST to create the directory. In order to save the output file at a given point in your job via syntax, there are two choices.

If you have SPSS 15, use the new OUTPUT SAVE command.
If you have SPSS 14 and programmability, use the viewer module SaveDesignatedOutput() method.

You can also handle the save with the SPSS Production Mode application.

You can do a save with a SaxBasic function, but it is difficult to synchronize that with your syntax stream.

If you can use the OMS output, you can save selected output that way and bypass the Viewer document altogether.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Egon Kraan
Sent: Wednesday, October 18, 2006 9:21 AM
To: [hidden email]
Subject: [SPSSX-L] Create File Folder with Syntax

I was just wondering if it was possible to create a directory file folder
using syntax and then save the output file in it?

Egon Kraan
Research Analyst
TNS NFO
600 Vine Street, Suite 300
Cincinnati, Ohio 45202

Phone: (513) 345-6735
Fax: (513) 461-7989
Email: [hidden email]
Web: www.tns-global.com
----------------------------------------------------------------------------
------------
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the addressee or authorized to receive this for the
addressee,
you must not use, copy, disclose or take any action based on this message
or any information herein. If you have received this message in error,
please advise the sender immediately by reply e-mail and delete this
message. Thank you for your cooperation.
----------------------------------------------------------------------------
------------
Reply | Threaded
Open this post in threaded view
|

Re: Create File Folder with Syntax

Jignesh Sutar
How do I create a folder if it does not exist, and to ignore the command if
it already exist?

I want to include it at the start of my syntax but for it not to fire out
errors when I re-run the syntax.

Many thanks!
Jigs
2006/10/18 King Douglas <[hidden email]>

> If you have SPSS 14 or 15 and Python, you can create new directories from
> inside SPSS by invoking the os module.  The following will create a new
> directory "makedir" given that the "TEMP" directory already exists.
>
>  BEGIN PROGRAM.
>  import os
>  os.mkdir("C:\TEMP\\makedir")
>  END PROGRAM.
>
>  If the "TEMP" directory does not already exist, you can create both the
> parent and the child directories in one statement (note differences in
> function call and path delimiters):
>
>  BEGIN PROGRAM.
>  import os
>  os.makedirs("C:\\TEMP\\makedir")
>  END PROGRAM.
>
>  King Douglas
>  American Airlines Customer Research
>
> "Peck, Jon" <[hidden email]> wrote:
>  You have seen how to use HOST to create the directory. In order to save
> the output file at a given point in your job via syntax, there are two
> choices.
>
> If you have SPSS 15, use the new OUTPUT SAVE command.
> If you have SPSS 14 and programmability, use the viewer module
> SaveDesignatedOutput() method.
>
> You can also handle the save with the SPSS Production Mode application.
>
> You can do a save with a SaxBasic function, but it is difficult to
> synchronize that with your syntax stream.
>
> If you can use the OMS output, you can save selected output that way and
> bypass the Viewer document altogether.
>
> Regards,
> Jon Peck
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Egon Kraan
> Sent: Wednesday, October 18, 2006 9:21 AM
> To: [hidden email]
> Subject: [SPSSX-L] Create File Folder with Syntax
>
> I was just wondering if it was possible to create a directory file folder
> using syntax and then save the output file in it?
>
> Egon Kraan
> Research Analyst
> TNS NFO
> 600 Vine Street, Suite 300
> Cincinnati, Ohio 45202
>
> Phone: (513) 345-6735
> Fax: (513) 461-7989
> Email: [hidden email]
> Web: www.tns-global.com
>
> ----------------------------------------------------------------------------
> ------------
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you are not the addressee or authorized to receive this for the
> addressee,
> you must not use, copy, disclose or take any action based on this message
> or any information herein. If you have received this message in error,
> please advise the sender immediately by reply e-mail and delete this
> message. Thank you for your cooperation.
>
> ----------------------------------------------------------------------------
> ------------
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Create File Folder with Syntax

Marta Garcia-Granero
J Sutar escribió:
> How do I create a folder if it does not exist, and to ignore the command if
> it already exist?
>
> I want to include it at the start of my syntax but for it not to fire out
> errors when I re-run the syntax.

Have you tried this one?

HOST COMMAND=['IF not exist C:\Temp MD C:\Temp'].

Best regards,
Marta

--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD