how to recursively delete directory starting with "xxxxx"? - visual-c++

I need to delete Directories that are starting with particular String "user"and i need to delete all the sub-folders in the Directory too.
I used removedirectory which deletes directory only when it is empty.

Normally I would open a command window then cd to the directory you want to delete,
Enter the command: "del /S /F *.* *" to delete all files and subdirectories.
Backup to the parent directory: cd ..
Remove the directory: rmdir "user*"
Use "del/?" to see all the options for del.
If you have to do this in c++, you can use the "system()" call.
BTW: I did not test this just now, so no guarantee.

Related

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 do I delete node_modules folder quickly?

When I want to delete a node_modules folder it takes ages when I delete it using Windows Explorer. How do I delete faster?
I use to have the same issue, taking hours to achieve the deletion until I found this workaround:
Select the node_modules folder. Do this with the file explorer.
Open Powershell as admin: press Alt+F, then S, then A.
Wait and accept to open Powershell as admin
Paste this command and press Enter: del /f/q/s *.* > nul.
WARNING
Please be sure to be in the folder node_modules. I mean, that the terminal path ends with ...\node_modules.
In the above command, we use the /f switch to force the deletion of read-only files. The /q switch enables quiet mode. The /s switch executes the command for all files in any folder inside the folder you’re trying to remove. Using *.* tells the del command to delete every file and > nul disables the console output improving performance and speed.
Wait for the process to take action.
Now go up one level in the directory with cd...
Finally use this command to delete the node_modules folder rmdir /q/s node_modules
In the above command, we use the /q switch to enable quiet mode, the /s switch to run the command on all the folders, and node_modules is the variable you need to specify to delete the folder you want.
If you get an error with Powershell try other terminals as administrator like Windows Terminal, Command Prompt (cmd) or third party terminals like ConEmu. I made this steps with Cmder and all the deletion was done in just 5 minutes. Off course this duration is variable according to the size of the folder.
References:
pureinfotech.com
ConEmu
Cmder
From you project folder use following command to delete it:
rd .\node_modules\ /s /q

How can I execute a command anywhere if certain required files are different directories?

Let say the command be my_command
And this command has to be prepared specific files (file1, file2, and file3) in the current working directory.
Because I often use my_command in many different directories, I'd like to keep the certain files in a certain directory and execute my_command without those three files in the working directory.
I mean I don't want to copy those three files to every working directory.
For example:
Directory containing the three files /home/chest
Working directory: /home/wd
If I execute command my_command, it automatically recognizes the three files in /home/chest/
I've thought the way is similar to add $PATH and not the executable files but just files.
It seems like the files needs to be in the current working directory for the vasp_std command to work as expected, I am thinking that you could simply add all files in a include folder in you home directory and then create a symbolic link to this folder from your script. In the end of your script the symbolic link will then be deleted:
#!/bin/bash
# create a symbolic link to our resource folder
ln -s ~/include src
# execute other commands here
# finally remove the symbolic link from the current directory
unlink src
If the vasp_std command require that the files are placed directly under the current working directory you could instead create a symbolic link for each file:
#!/bin/bash
# create link for to all resource files
for file in ~/include/*
do
ln -s $file `basename $file`
done
# execute other commands here
# remove any previously created links
for file in ~/include/*
do
unlink `basename $file`
done

How to delete all files in one particular directory

In Linux, how can I delete all files in particular directory? For example /home/xd/karthik is my path; I want to delete all files in the above directory, if the disk usage exceeds 90%. How can I write a script for that?
rm /path/to/directory/*
add rm -r to remove the file hierarchy rooted in each file argument.
dont need script just basic shell command

Delete directory content using 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?

Resources