What is the order that rd command processes files and folders - windows

I am a bit troubled these days because I just started deleting C:/ on a production server.
I just wanted to remove c:/$Recycle.bin to clean some disk space.
But when I attempted to type $, I accidentally pressed Enter instead of shift, because these are very close buttons on my keyboard.
So the command went to delete C:/ .... :( Luckily, I didn't run the cmd with administrator rights and I only removed a few GB because of permissions.
I can recover the wasted files because the machine is protected with backups.
But how may I know what files have been deleted and what havn't?
Does anybody know in what order RD command (remove directory) processes the files / folders ? Alphabetically or...
I'd be happy if someone can help.

Related

Unable to find files in Documents from cmd

I am using Windows 10 and when I save a document I see the Documents folder it is being saved to on the left of the screen in the list under 'thisPC'. The bottom of that list has the C: drive. From Powershell, Bash or command prompt when I try to cd or locate the file I just saved I am told that it cannot find such a file. Why is my home directory the C: and not include the other files I mainly work with? I appreciate any help. Thank you
Command prompt works with files and folders.
Explorer works with virtual files or folders. Explorer is for users to easily find their stuff.
In Command prompt there is no such thing as This PC or anything under it. These are virtual things.
dir "%userprofile%\documents"
will list the files in your Documents folder if it is in the default location.

Windows 7 - undeletable file after git conflict

I recently had a git conflict, and rather than dealing with it properly, I didn't actually fix any of the conflicts, but did something like overwrite the files with another version from another clone of the repo, or moved the files out of the directory, or did a git reset --soft, or some other convoluted series of commands.
Anyway, I've been left with some files on my filesystem that I cannot delete. I cannot move them, rename them, delete them with DEL in the command line, or with RM in gitbash. The file is named:
pom.xml~9b19d48... dpom_refactor
It has 0 bytes, and I've no clue how to get rid of it. I no longer have any .git folder, so I can't use any git commands to rollback what I did. Whenever I attempt to delete/move/rename, I get the error:
Could not find this item
This is no longer located in C:\<filePath>. Verify the item's location and try again.
Any thoughts on how I could get rid of it?
This kind of invalid Windows filename could be dealt with like a nul file.
C:\> rename \\.\C:\..\pom.xml~9b19d48... dpom_refactor del.txt
C:\> del del.txt
Using the \\.\ prefix tells the high-level file I/O functions to pass the filename unparsed to the device driver
If that was to fail, only a dedicated tool (or Live Linux distro CD) would be able to mount that disk and remove the file.

Running program/macro to rename, add files to flash drive

I have a huge batch of flash drives that I need to move files onto. I'd also love to rename the drives (they're all called NO NAME by default). I'd love to plug two drives in, run a terminal script on the computer to accomplish all of that (most importantly the file moving). Then remove the drives, put the next two in, run it again, etc. until I'm done. All of the drives are identically named.
Is batch executing like this possible, and does anyone know how to go about doing it?
I figured it out. Put each one in and run this command to rename the drive and then move the files into it:
diskutil rename /Volumes/OLDNAME "NEWNAME" && cp -r ~/Desktop/sourceFolder/. /Volumes/NEWNAME

Why does mkdir occasionally give Access Denied?

I have BAT scripts which are nothing tricky and work fine on XP. But on Win 7, about 1 in 5 executions of mkdir following rmdir give a mystery Access Denied. E.g.
S:\TLIB importing\! Curtains\2 To process>rmdir temp3allout /s /q
S:\TLIB importing\! Curtains\2 To process>mkdir temp3allout
Access is denied.
After this, when I try in Explorer, it has no problem making that directory. Running thatBAT again usually succeeds.
Any idea what's going on here?
Win XP disc was a regular 2Gb drive. Win 7 disc is a 2Gb Intel RST RAID1 array with caching and flushing disabled http://i.imgur.com/Ohqkg2t.png .
This happens when the file system hasn't finished deleting the directory yet.
Sometimes this will happen synchronously, i.e., before the rmdir command completes, but sometimes there will be a very short but nonzero delay. (In XP it was always synchronous, IIRC.)
If possible, avoid deleting and immediately recreating directories; if you can't avoid it, you'll need to detect the failure and retry.
You should probably also test and if necessary retry the rmdir; sometimes rmdir runs into the same problem and fails to delete the entire directory tree.
Because that directory or file in that directory is open in some editor,first you have to close that file/directory from editor and then try.
These error usually comes when we create some directory and then delete it,but it is partially deleted and we create new directory with same name.

Problem deleting .svn directories on Windows XP

I don't seem to have this problem on my home laptop with Windows XP, but then I don't do much work there.
On my work laptop, with Windows XP, I have a problem deleting directories when it has directories that contain .svn directories. When it does eventually work, I have the same issue emptying the Recycle bin. The pop-up window says "Cannot remove folder text-base: The directory is not empty" or prop-base or other folder under .svn
This continued to happen after I changed config of TortoiseSVN to stop the TSVN cache process from running and after a reboot of the system.
Multiple tries will eventually get it done. But it is a huge annoyance because there are other issues I'm trying to fix, so I'm hoping it is related.
'Connected Backup PC' also runs on the laptop and the real problem is that cygwin commands don't always work. So I keep thinking the dot files and dot directories have something to do with both problems and/or the backup or other process scanning the directories is doing it. But I've run out of ideas of what to try or how to identify the problem further.
You don't need to reboot; just open Task Manager and kill TSVNCache.exe.
This is safe, too. It's designed so you can kill it and it will automatically restart when needed.
(As a result of the auto-restart, note that browsing some SVN folders in Explorer, File-Open dialogs, etc. may cause TSVNCache.exe to restart. Keep an eye on Task Manager.)
Tortoise SVN is great but I have found that TSVNCache.exe can hold on to locks and get in the way at times. (Sometimes justified, sometimes not.) As a result, for some automated scripts I run I include commands to kill TSVNCache.exe as part of the scripts so it doesn't get in the way. That's only worth doing if it's an operation you perform often, though.
You can try a few things:
Since you are getting this error frequently, you can use handle.exe from sysinternals to check which process currently have open handles for the .svn\* directory. If handle utility tells you about any process, try stopping that process and then delete the directories.
Error while deleting from recycle bin: In simple terms, when a file is sent to recycle bin after deleting, it is not actually deleted, rather, a few manipulations are done in directory hierarchy (file system level) to avoid showing the file while browsing content of a folder. So If you happen to resolve the problem mentioned in comment#1, you will not get this error probably.
Cygwin command not working: Running a cygwin command on windows requires (in particular) cygwin1.dll, which is known to be shipped with other programs (eg: CopSsh, some version of svn clients etc...) as well. If there is any mismatch in the version of cygwin1.dll, cygwin commands won't work. Try searching for cygwin1.dll on your computer and try to resolve version conflicts (if any).
did you ever do mkpasswd and mkgroup for cygwin? If you're using cygwin from the command line you are pretty much guaranteed to have file system permissions issues. and you have to read a little to fix it.
http://cygwin.com/cygwin-ug-net/ntsec.html
Try this answer from me. Although it's given for TortioseGit instead of TortoiseSVN, the handling is the same:
disable the status cache (i.e. prevent the TSVNCache.exe from accessing the .svn folders continuously)
delete what you have to delete
enable the status cache to get updated overlays again
I have just experienced this problem (or similar)
I am using tortoise 1.6.7
To fix it I went to 'Tortoise Settings' from the tortoise context menu.
from there select "Icon Overlays" in the tree widget.
In the icon overlays page, I entered the path that was giving me angst into the "exclude paths:"and tortoise no longer holds that directory handle.
This is a directory that is often deleted by a process other than explorer.
Since what it appears that you are trying to do is export the repository from SVN, why not use the export functionality with TortoiseSVN. This removes all .svn directories from the generated 'working copy'.Cmdline: http://svnbook.red-bean.com/en/1.0/re10.html
If you want to delete all sub folders named .svn in windows
then create batch file with this content:
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (
rd /s /q "%%i"
)
save it in a file del_All_Dot_SVN_Folders.cmd . Run it. Your done.
Thanks to http://www.axelscript.com/2008/03/11/delete-all-svn-files-in-windows/
Remember the above code has .svn whereas the code in the link has only *svn so its better
to have the .svn to not accidentally have undesired effect.

Resources