sftp uploading to non-existing directory - directory

Say I have to upload file dir-a/dir-b/dir-c/xxx.txt using sftp
Should I create the target directory first?
Should I open target directory before copying the file?
If have to create this path dir-a/dir-b/dir-c - is it one command or three?

Should I create the target directory first?
Usually yes. SFTP servers usually do not create parent directory. But how hard is it to try first?
Should I open target directory before copying the file?
You do not have to. put command does accept a remote-path, which can be either absolute or relative to remote working directory.
If have to create this path dir-a/dir-b/dir-c - is it one command or three?
These are three commands:
mkdir dir-a/
mkdir dir-a/dir-b/
mkdir dir-a/dir-b/dir-c

Related

Winzip command line - Include full path information

How do I use winzip command line with include full path information ? I know I can do this under Winzip GUI but how to do it using cmd ? Also, is there a way to zip selected specific folders only ? Thanks
Tried GUI and it is working very slow
Winzip command line doesnt seem to zip selected folders - either parent folders or specific subfolders
I am using winzip 27 command line and this is the syntax I am using:
wzzip -a -e0 -k -P -r -yx "C:\Users\source\to\save\zipfile.zip" "C:\example"
This stores files and folder timestamps underneath C:\example. But since I have enabled -P -r, I want to store the timestamps of the upper folder, C:\example folder. How can I do that ? Does anyone have suggestions?
Also, how do I specify the path for a mapped network drive? Thanks!

WinSCP script to synchronize directories, but exclude several subdirectories

I need to write a script that synchronizes local files with a remote machine.
My file structure is:
ProjectFolder/
.git/
input/
output/
classes/
main.py
readme.md
I need to synchronize everything, but:
completely ignore .git folder
ignore files in input and output folders, but copy the folder
So far my code is:
open sftp://me:password#server -hostkey="XXXXXXXX"
option batch abort
option confirm off
synchronize remote "C:\Users\MYNAME\Documents\MY FOLDER\Python Projects\ProjectFolder" "/home/MYNAME/py_proj/ProjectFolder" -filemask="|C:\Users\MYNAME\Documents\MY FOLDER\Python Projects\ProjectFolder\.git"
close
exit
First question: it doesn't seems to work.
Second question, how to add mask for input and output folder if I have spaces in file paths?
Thanks to all in advance.
Masks for directories have to end with a slash.
To exclude files in a specific folder, use something like */folder/*
-filemask="|.git\;*/input/*;*/output/*"

Rsync Specific Listed Files from specified Server Directory

I'd like to rsync specified files from a specific server folder to my local directory (in which I am running the command).
However, I'm getting the error failed: No such file or directory (2). There seems to be something wrong with my syntax and I'm not sure its picking up the source directory properly
This is my command...
rsync -az . remoteSite.com::remoteFolder/remoteSubFolder/ --files-from=filelist.txt
filelist.txt, which it seems to be finding, contains filenames within remoteSubFolder
file1.xml
file2.xml
etc
What am I doing wrong?
Thanks to #Gordon Davisson.
I now understand that the full stop represents the local directory and goes after the remote host and directory.
rsync -az --files-from=filelist.txt remoteSite.com::remoteFolder/remoteSubFolder/ .

Manipulating multiple files with same name

I am trying to move about 1000 files that all begin with "simulation." into one directory entitled "simulations." I am using a remote server, and the files are currently in my home directory on the server. I need to move them to a separate directory because I need to, ultimately, append all the "simulation." files into one file. Is there a way to either append only the files in my home directory that begin with "simulation." or move only these files into a new directory?
Thank you.
Assuming you can change directories to the desired path on the remote server... and the simulations are located in /currentPath ... then....
cd desiredPath
mkdir simulations
mv /currentPath/simulation* simulations
(to futher answer your question... if you wanted to append all the files together, you could type cat simulation* > allSimulations.txt

Recursively copy files that match a wildcard combination but not create the directory tree in DOS

I found that I can use xcopy /s to copy all files that match a wildcard combination in a folder to another location. But this command re-creates the folder structure. I do not want the tree. I need just the files dumped into the destination folder. There are no duplicate files in the source folder.
You can use for command:
for /R %%x in (*.cpp) do copy "%%x" "c:\dest\"
If you want to run it directly from command prompt (not from a batch file) use %x instead of %%x.
For your purpose, instead of using xcopy you should use robocopy:
http://en.wikipedia.org/wiki/Robocopy
http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx

Resources