diff --git a/luigi/file.py b/luigi/file.py
index <HASH>..<HASH> 100644
--- a/luigi/file.py
+++ b/luigi/file.py
@@ -8,6 +8,12 @@ class File(object):
         return os.path.exists(self.__path)
 
     def open(self, mode = 'r'):
+        if mode == 'w' or mode == 'a':
+            # Create folder if it does not exist
+            normpath = os.path.normpath(self.__path)
+            parentfolder = os.path.dirname(normpath)
+            if not os.path.exists(parentfolder):
+                os.makedirs(parentfolder)
         return open(self.__path, mode)
     
     def remove(self):
LocalTarget and File create folder while creating a new file

Change-Id: Ie8e2ba3bf<I>ed<I>c<I>b<I>e<I>