To delete a file on the server, type del and then the filename or filenames:
del oldfile.dat
del file1.txt file2.txt
del *.o
Files will be deleted without further prompting, even if multiple files are specified.
del will only delete files. You cannot use it to delete directories; use rmdir for that.
The rm command works exactly the same way as del.
6.2.16 The mkdir command: create remote directories
To create a directory on the server, type mkdir and then the directory name:
mkdir newstuff
You can specify multiple directories to create at once:
mkdir dir1 dir2 dir3
6.2.17 The rmdir command: remove remote directories
To remove a directory on the server, type rmdir and then the directory name or names:
rmdir oldstuff
rmdir *.old ancient
Directories will be deleted without further prompting, even if multiple directories are specified.
Most SFTP servers will probably refuse to remove a directory if the directory has anything in it, so you will need to delete the contents first.
6.2.18 The mv command: move and rename remote files
To rename a single file on the server, type mv, then the current file name, and then the new file name:
mv oldfile newname
You can also move the file into a different directory and change the name:
mv oldfile dir/newname
To move one or more files into an existing subdirectory, specify the files (using wildcards if desired), and then the destination directory:
mv file dir
mv file1 dir1/file2 dir2
mv *.c *.h ..
The rename and ren commands work exactly the same way as mv.
6.2.19 The ! command: run a local Windows command
You can run local Windows commands using the ! command. This is the only PSFTP command that is not subject to the command quoting rules given in
section 6.2.1
. If any command line begins with the ! character, then the rest of the line will be passed
straight to Windows without further translation.
For example, if you want to move an existing copy of a file out of the way before downloading an updated version, you might type:
psftp> !ren myfile.dat myfile.bak