Windows Command Line in VisualNeo Win
They were answered in terms of the Windows Command Line using the VisualNeo command ‘Run‘. The Windows Command Line offers many commands that can be useful for you.
Runing these commands is in VisualNeo easy. I prefer to use ‘cmd.exe /c’ before the command.
Run "cmd.exe" "/c DEL D:\test\test?.*" "Wait+Hidden" "" ""
in order to delete all files in the directory D:\test with a filename starting with ‘test’
In this blog, I quote some examples from my eBook on the Windows Command Line.
Are you interested in more, go to amazon.com and take a look at my book.
1.1 Copy files from the current directory into a subdirectory
To copy ‘file1.txt’ from our example directory ‘D:\test’ into the subdirectory ‘my Doc’, we could type
D:\test>COPY file1.txt "my Doc" [ENTER]
To copy the files ‘file1.txt’, ‘file2.dat’, ‘file2.txt’ and ‘file3.txt’ to ‘my Doc’, use Glob patterns:
D:\test>COPY file?.* "my Doc" [ENTER]
where the question mark ? refers to the number 1, 2 and 3 and the pattern ‘.*’ matches all extensions.
1.2 Copy files from the current directory into a subdirectory in binary mode
The default copy behavior treats files as ASCII-files, as lines of text (with end-of-line characters, end-of-files etc.). The command
D:\test>COPY *.jpg "my Doc" [ENTER]
will copy the image files with extension ‘.jpg’ into the subdirectory ‘my Doc’. However, loading those images into an image viewer will probably give errors. To avoid this, you should use the binary mode: in this case the files are copied byte for byte. Simply add the switch ‘/B’ to the ‘COPY’ command:
D:\test>COPY /B *.jpg "my Doc" [ENTER]
1.3 Are the files copied correctly?
2.1 Delete files from the current directory
To delete or erase file1.txt, file2.txt, file2.dat and file3.txt from our example directory D:\test, we could type:
D:\test>DEL file?.* [ENTER]
(as we saw earlier)
Another example: the command
D:\test>DEL *.jpg [ENTER]
will delete all image files with extension ‘.jpg’ from our example directory.
To delete also files with the attribute read-only, you have to add the switch ‘/F’ as a parameter to the ‘DEL’ command.
D:\test>DEL /F *.jpg [ENTER]
2.2 Delete files from a subdirectory
To delete files from the subdirectory ‘my Doc’, use
D:\test>DEL "my Doc"\* [ENTER]
or still shorter
D:\test>DEL "my Doc" [ENTER]
Notice that the subdirectory will not be erased; only the files will be deleted.
D:\test>RD "my Doc" /S [ENTER]
will erase the subdirectory ‘my Doc’ and all its files (‘RD’ is an abbreviation of Remove Directory; for also deleting subdirectories, the switch ‘/S’ is necessary).
‘ROBOCOPY’ is very efficient in deleting files and (sub)directories.
D:\>ROBOCOPY /MOV /S /E D:\test D:\test_backup
With the /MOVE switch, you can delete both files and directories.
To check if Robocopy is available on your system, use the command after the prompt: Robocopy /? [ENTER]
2.4 Secure file deletion
firstly you turn an existing file into a zero-byte file, secondly you delete the file via the ‘DEL’ command and thirdly you run the ‘CIPHER’ command:
D:\test>TYPE nul >file1.txt && DEL file1.txt [ENTER]
(Use the ‘FOR’ command to delete more than one file).
After deleting your files, you run the ‘CIPHER’ command that will overwrite deleted files, i.e. free disk space, maybe freeing up some extra disk space.
D:\test>CIPHER /w:D:\test [ENTER]
In one command line:
D:\test>TYPE nul >file1.txt && DEL file1.txt && CIPHER /w:D:\test [ENTER]
D:\test>CIPHER /? [ENTER]
for lots of information on the ‘CIPHER’ command!