Thursday 7 October 2010

Useful Windows Batch File Commands

This post has moved to my new website, if not redirected automaticaly please click here: https://anthonyblake.github.io/windows/cli/2010/07/10/useful-win-batch-commands.html 

The following code checks if a directory exists, if not it is created. It then moves a file into that directory.

This is ideal code to run before an ftp script as it will prevent a half written file being transmitted via FTP.

@echo off
if not exist "C:\Folder\Destination"
(

md "C:\Folder\Destination"
)
move "C:\Folder\Source\*.*"
"C:\Folder\Destination"

pause

The pause command lets you see the results of the script. Remove it if automated on a Windows Scheduled Task.

No comments:

Post a Comment

Thanks for the feedback!