rmdir

Deleting directories using single liner command

倾然丶 夕夏残阳落幕 提交于 2019-12-12 09:56:37
问题 How to remove more than one directory using single command? Is it possible to do it in one liner? If yes, Please help on this. /osmf/mgmt/scheduler>ls -lrt total 22 drwx------ 2 root root 12288 Mar 26 2009 lost+found drwxr-xr-x 4 ctmagent controlm 1024 May 24 2010 ctmagent drwxrwxrwx 3 edwprod edw 1024 Dec 1 09:53 edi drwxrwxrwx 120 edwprod edw 5120 Dec 27 09:37 edw /osmf/mgmt/scheduler> Can I delete edi and edw using a single command? 回答1: rm -r edi edw rm can take an arbitrary number of

Recursive delete

ぐ巨炮叔叔 提交于 2019-12-12 07:16:10
问题 I have this code to recursive delete files and directories. It works fine but has a little problem. If $path = /var/www/foo/ it will delete everything inside of foo, but not foo. I want to delete foo directory too. Any idea? public function delete($path) { if(!file_exists($path)) { throw new RecursiveDirectoryException('Directory doesn\'t exist.'); } $directoryIterator = new DirectoryIterator($path); foreach($directoryIterator as $fileInfo) { $filePath = $fileInfo->getPathname(); if(!

Delete files then directory

倾然丶 夕夏残阳落幕 提交于 2019-12-08 02:11:52
问题 I have this so far: <?php $path = "files/"; $files = glob("" . $path . "{*.jpg, *.gif, *.png}", GLOB_BRACE); $i = 0; foreach($files as $file) { $delete = unlink($file); if($delete) { echo $file . " deleted!<br />"; $i - 1; } else { echo $file . " could not be deleted...<br />"; $i + 1; } } if($i == 0) { if(is_dir($path)) { $remove = rmdir($path); if($remove) { echo "directory was deleted</br />"; } else { echo "directory could not be deleted</br />"; } } else { echo "not a valid directory<br

In PHP how do I recursively remove all folders that aren't empty? [duplicate]

给你一囗甜甜゛ 提交于 2019-12-06 16:26:00
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I recursively delete a directory and its entire contents (files+sub dirs) in PHP? I need to recursively delete a directory and subdirectories that aren't empty. I can't find any useful class or function to solve this problem. In advance thanks for your answers. 回答1: From the first comment in the official documentation. http://php.net/manual/en/function.rmdir.php <?php // When the directory is not empty:

Delete files then directory

。_饼干妹妹 提交于 2019-12-06 08:03:01
I have this so far: <?php $path = "files/"; $files = glob("" . $path . "{*.jpg, *.gif, *.png}", GLOB_BRACE); $i = 0; foreach($files as $file) { $delete = unlink($file); if($delete) { echo $file . " deleted!<br />"; $i - 1; } else { echo $file . " could not be deleted...<br />"; $i + 1; } } if($i == 0) { if(is_dir($path)) { $remove = rmdir($path); if($remove) { echo "directory was deleted</br />"; } else { echo "directory could not be deleted</br />"; } } else { echo "not a valid directory<br />"; } } else { echo "there are some files in the folder"; echo $i; } ?> It deletes every file, which

Deleting directories using single liner command

爱⌒轻易说出口 提交于 2019-12-05 22:14:59
How to remove more than one directory using single command? Is it possible to do it in one liner? If yes, Please help on this. /osmf/mgmt/scheduler>ls -lrt total 22 drwx------ 2 root root 12288 Mar 26 2009 lost+found drwxr-xr-x 4 ctmagent controlm 1024 May 24 2010 ctmagent drwxrwxrwx 3 edwprod edw 1024 Dec 1 09:53 edi drwxrwxrwx 120 edwprod edw 5120 Dec 27 09:37 edw /osmf/mgmt/scheduler> Can I delete edi and edw using a single command? rm -r edi edw rm can take an arbitrary number of arguments, and the -r flag makes it delete directories recursively. Refer to man rm for more details. And, BTW,

In PHP how do I recursively remove all folders that aren't empty? [duplicate]

笑着哭i 提交于 2019-12-04 22:04:37
This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I recursively delete a directory and its entire contents (files+sub dirs) in PHP? I need to recursively delete a directory and subdirectories that aren't empty. I can't find any useful class or function to solve this problem. In advance thanks for your answers. lorenzo-s From the first comment in the official documentation. http://php.net/manual/en/function.rmdir.php <?php // When the directory is not empty: function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object)

Cannot delete a file even when logged in as an Administrator [closed]

冷暖自知 提交于 2019-12-03 09:35:21
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Please could some tell me what I am doing wrong. I am trying to delete hidden folder through command line. I am running the command line as administrator but still getting message insufficient access. Here is screenshot of my command line : Here is the code i am trying rmdir "c:\xampp\htdocs\prestashop\dfs" I am getting errors like: Cannot remove item .... You do not have sufficient access rights to perform this

Finding empty directories in Python

左心房为你撑大大i 提交于 2019-11-30 11:36:04
问题 All, What is the best way to check to see if there is data in a directory before deleting it? I am browsing through a couple pages to find some pics using wget and of course every page does not have an image on it but the directory is still created. dir = 'Files\\%s' % (directory) os.mkdir(dir) cmd = 'wget -r -l1 -nd -np -A.jpg,.png,.gif -P %s %s' %(dir, i[1]) os.system(cmd) if not os.path.isdir(dir): os.rmdir(dir) I would like to test to see if a file was dropped in the directory after it

git - how to remove empty folder and push that change?

只愿长相守 提交于 2019-11-29 21:12:46
How can I remove an empty folder locally and also have that happen for other collaborators that share the remote via pull-push? I know that folders aren't 'tracked' in that sense by git but the question remains. e.g. I moved a file to another folder and committed the change (of the move). But I can't git rm name the folder as I get "doesn't match" git rmdir name doesn't exist. I can do a git clean -f folder but how does that get pushed up? I can directly rm the file but how do I get that directory removal done correctly and pushed to the repository and then out to others when they pull so that