Delete directory content using WinSCP - winscp

Is there a way to delete directory content using WinSCP?
I tried this, but it doesn't work:
synchronize remote -delete

To delete a directory, use the rm command.
The synchronize ... -delete deletes only orphan files or directories.
See also How do I create script that synchronizes files and deletes synchronized files from source afterward?

Related

Copy files within multiple directories to one directory

We have an Ubuntu Server that is only accessed via terminal, and users transfer files to directories within 1 parent directory (i.e. /storage/DiskA/userA/doc1.doc /storage/DiskA/userB/doc1.doc). I need to copy all the specific files within the user folders to another dir, and I'm trying to specifically target the .doc extension.
I've tried running the following:
cp -R /storage/diskA/*.doc /storage/diskB/monthly_report/
However, it keeps telling me there is no such file/dir.
I want to be able to just pull the .doc files from all the user dirs and transfer to that dir, /storage/monthly_report/.
I know this is an easy task, but apparently, I'm just daft enough to not be able to figure this out. Any assistance would be wonderful.
EDIT: I updated the original to show that I have 2 Disks. Moving from Disk A to Disk B.
I would go for find -exec for such a task, something like:
find /storage/DiskA -name "*.doc" -exec cp {} /storage/DiskB/monthly_report/ \;
That should do the trick.
Use
rsync -zarv --include="*/" --include="*.doc" --exclude="*" /storage/diskA/*.doc /storage/diskB/monthly_report/

How to delete files from specific folders in linux?

So, I have a requirement to delete all files from specific folders within a directory. These are folders that end with "-outputs" in their names and I need to delete all files in those particular folders.
Is there a command in linux that lets you do that?
You can execute the following command:
rm $YOUR_PATH\*-outputs
Change $YOUR_PATH to the path where the files are located.
If you want to ignore nonexistent files and arguments, and avoid the prompt, you can use the -f option.
rm -f $YOUR_PATH\*-outputs
You can see the different rm options here:
rm Linual manual page

How to recursively delete files and folders under a certain directory using command line?

I am a beginner of Linux system. Now I have a butch of files and folders want to be deleted. How can delete them one time using some command line?
Firstly I think you need rm command, then since you want to recursively delete the files or folders, you have to choose the option -r, -r means recursively delete something. Below is the link for details using rm command in Linux system.
https://www.computerhope.com/unix/urm.htm

how to rsync files and keep files that have been deleted in the source?

I was trying to see if its possible to rsync a bunch of files from a website but, if the website deleted files, I don't want rsync to delete those files on my end and keep them.
currently as a starting point I'm doing:
```rsynch -av "link" /repo/
how do I make sure that files that were deleted in the link do not delete when I rsync the repo for updates?
rsync does not delete by default. You have to request that in a specific manner using the --delete switch. Check the rsync manual page as a reference: man rsync
#arkascha

Copy files excluding some folder in linux

I want to create script that copy my project and make it zip archive. I want to exclude all folder named .svn in all sub directories. Any suggestion?
I'd use rsync's FILTER RULES for this:
Create an .rsync-filter file (in the origin directory) containing, e.g.
-.svn/
Now run rsync like an exalted copy:
rsync -aFF origin/ destination/
You can do this using rsync. Although this is designed to synchronise directories across servers, it can also be used to copy directories on a single machine.
rsync has a --exclude option to exclude files and directories by pattern. See http://www.samba.org/ftp/rsync/rsync.html for help and examples.
Just call the zip utility on your project’s folder and use the -r option for recursive plus the -x option to exclude files / folders by pattern.
zip -r target-filename.zip source-folder -x \*exclude-pattern\*
exclude-pattern in your case would be .svn
See also man zip

Resources