Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = #define private public - Getting rid of <tt>nul</tt>, or: How I learnt to love UNC (29 Apr 2006) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="29"></a> ---+++ [[BlogOnSoftware20060429][Getting rid of <tt>nul</tt>, or: How I learnt to love UNC]] (29 Apr 2006) Every now and then, some tool on my system runs berserk and starts to generate files called =nul=. This is a clear indication that there's something going wrong with output redirection in a script, but I still have to figure out exactly what's going on. Until then, I need at least a way to get rid of those files. Yes, that's right, you cannot delete a file called =nul= that easily - neither using Windows Explorer nor via the DOS prompt. [[http://en.wikipedia.org/wiki//dev/null][nul]] is a very special filename for Windows - it is an alias for the null device, i.e. the bit bucket where all the redirected output goes, all those cries for help from software which we are guilty of ignoring all the time. [[http://www.uwplatt.edu/oit/terms/uncpath.html][UNC]] path notation to the rescue: To remove a file called =nul= in, say =c:\temp=, you can use the DOS =del= command as follows: <pre> del \\.\c:\temp\nul </pre> Works great for me. But since I rarely use UNC syntax, I sometimes forget how it looks like. Worse, the syntax requires to specify the full path of the =nul= file, and I hate typing those long paths. So I came up with the following naïve batch file which does the job for me. It takes one argument which specifies the relative or absolute path of the =nul= file. Examples: <pre> rem remove nul file in current dir delnul.bat nul rem remove nul file in subdir delnul.bat foo\nul rem remove nul file in tempdir delnul.bat c:\temp\nul </pre> For the path completion magic, I'm using the [[http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx?mfr=true][for]] command which has so many options that my brain hurts whenever I read its documentation. I'm pretty sure one could build a Turing-complete language using just =for=... <pre> @echo off set fullpath= for %%i IN (%1x) DO set fullpath=%%~di%%~pi set filename= for %%i IN (%1x) DO set filename=%%~ni if not "x%filename%" == "xnulx" (echo Usage: %0 [somepath\]nul && goto :eof) echo Deleting %fullpath%nul... del \\.\%fullpath%nul </pre> [[http://www.purgeie.com/delinv/index.htm][<nop>DelinvFile]] takes this a lot further; it has a Windows UI and can delete many other otherwise pretty sticky files - =nul= is not the only dangerous file name; there's =con=, =aux=, =prn= and probably a couple of other magic names which had a special meaning for DOS, and hence also for Windows. --- %STOPINCLUDE% %COMMENT{type="below" nonotify="on"}% ---
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.3 |
>
|
r1.2
|
>
|
r1.1
|
Total page history
|
Backlinks
You are here:
Blog
>
BlogOnSoftware20060429
r1.3 - 30 Apr 2006 - 12:45 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback