diff --git a/wmake/wclean b/wmake/wclean
index e2f6a3142c3154e1c7d45f2d6c097de1898d6846..de9bd6c58db73b9fcb41ed3babb91a0aa9465df3 100755
--- a/wmake/wclean
+++ b/wmake/wclean
@@ -100,10 +100,13 @@ MakeDir=Make
 
 if [ $# -ge 1 ]
 then
-
     if [ -d "$1" ]
     then
         dir=$1
+    elif [ -f "$1" ]
+    then
+        dir="${1%/*}"
+        : ${dir:=.}
     else
         targetType=$1
     fi
diff --git a/wmake/wmake b/wmake/wmake
index 38f3d3ff6e5e1ccfb4a0168871e04dd4719157a3..1c3ad99fa6f397048d2fe4abd6c24d38461ba418 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 #-------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -250,7 +250,11 @@ if [ $# -ge 1 ]
 then
     if [ -d "$1" ]
     then
-        dir=$1
+        dir="$1"
+    elif [ -f "$1" ]
+    then
+        dir="${1%/*}"
+        : ${dir:=.}
     else
         targetType=$1
     fi