Re: EXPORT TO DIFFERENT FOLDERS
- To: mathgroup at smc.vnet.net
- Subject: [mg108048] Re: EXPORT TO DIFFERENT FOLDERS
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 7 Mar 2010 04:04:24 -0500 (EST)
On 3/5/10 at 4:31 AM, jihane.ajaja at mail.mcgill.ca (jihane) wrote: >I am currently exporting different files to the folder set by >SetDirectory["..."]. I have a loop that produces 5 files at a time >and then start again and produce 5 other files. How could I ask the >program to put each of these 5 files in a specific folder I created >in the main folder ; the one set by SetDirectory["..."]? Do the folders exist at the time you write the files or do they need to be created? If they exist, you could either use SetDirectory to change the working directory as needed, write the files then use ResetDirectory to restore the working directory back to the main folder or use ToFileName[foldername, filename] to specify both the folder and filename when writing data to files. That is Export[ToFileName[foldername, filename], data, format] writes data to filename located in foldername located in the current working directory, i.e., the directory (folder) returned by Directory[]. If the folders don't exist, use CreateDirectory to create them then write data out as suggested above.