Give these a shot. Good luck!
Use some Robocopy tricks, quote:
Create a dummy folder on the drive (D: in this example) where the elongated path lives:
md AnyFolderName
Copy the dummy folder to the mutant folder using the /MIR (mirror) command line switch:
robocopy D:\AnyFolder D:\BackupFolder /MIR
Let RoboCopy clean up the fouled folder. This could take a few minutes depending on the size of the folder.
Remove the fixed folder and the dummy folder:
rd /s D:\BackupFolder
rd /s D:\AnyFolder
That’s it. You are good to go.
OR
Renaming...
I had one folder with multiple folders inside like that, and the way i
used is to rename the folder (main folder first then the next ones)
and i finally was able to delete the main folder without any tools...
OR
[Quote:][4]
I found out make a drive mapping about halfway into the folder structure you should be able to delete the latter half of the file heirarcy.
For example if you are getting the error trying to delete:
\\NAS.Device.Company.com\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
Then map a network drive Z: to
\\NAS.Device.Company.com\a\b\c\d\e\f\g\h\i\j\k\
This will reduce the file herarch down to a smaller path. Open explorer and view the Z: drive. It should contain a folder called L (in this example).
You should now be able to delete the L and its subfolders without an issue, thereby deleting half the folder hierarchy. After that, disconnect the z: drive and try to delete whatever is left normally. Problem solved!
OR
Use the Unlocker utility.
[4]: http://answers.microsoft.com/en-us/windows/forum/windows_vista-files/the-source-file-names-are-larger-than-is-supported/438a20a7-a964-4325-b755-8b5d75ddd15benter preformatted text here
BATCH FILE TO DELETE FROM SUBFOLDERS WITH DIFFERENT NAMES DYNAMICALLY USING WILDCARD FOR SUBFOLDER NAMES
Batch file to delete files from wildcard folder
Here's an easy and simple batch script example that I use to complete this type of task all the time, I plugged in the variable folder paths to suit your needs as you describe:
SAMPLE BATCH SCRIPT
(Set your variable root folder and subfolder up top, and the FOR /D
and FOR
loops iterate accordingly to do the rest of the magic traversing the directory as the logic specifies and completes the DEL /Q /F
command for the *.txt
files)
@ECHO ON
SET SourceDir=D:\L1
SET SourceSubDir=L3
:: --// note the asterisk wildcard after SourceDir in the first FOR /D loop using X as the variable
:: --// note the X variable appended to the beginning of the second FOR (no /D switch here) loop in the SET part using Y as the variable
FOR /D %%X IN ("%SourceDir%\*") DO FOR %%Y IN ("%%~X\%SourceSubDir%\*.txt") DO DEL /Q /F "%%~Y"
GOTO EOF
NOTE: If you plan to run this with a copy and paste manually in the command prompt, then the variables in the FOR
loops need to have one of the percent signs removed in all parts so use the below for that part if you're running this manually with a copy and paste rather than in a batch script and executing that which is how the above example will work.
FOR /D %X IN ("%SourceDir%\*") DO FOR %Y IN ("%~X\%SourceSubDir%\*.txt") DO DEL /Q /F "%~Y"
FURTHER DETAIL AND RESEACH
(Type in FOR /?
in Windows Command Prompt to see this detail)
FOR (with no switch)
Runs a specified command for each file in a set of files.
FOR %variable IN (set) DO command [command-parameters]
%variable Specifies a single letter replaceable parameter.
(set) Specifies a set of one or more files. Wildcards may be used.
command Specifies the command to carry out for each file.
command-parameters
Specifies parameters or switches for the specified command.
To use the FOR command in a batch program, specify %%variable instead
of %variable. Variable names are case sensitive, so %i is different
from %I.
If Command Extensions are enabled, the following additional
forms of the FOR command are supported:
FOR /D
FOR /D %variable IN (set) DO command [command-parameters]
If set contains wildcards, then specifies to match against directory
names instead of file names.
Best Answer
Your batch file will need to run two commands, one to clear out the files then one to remove the child directories. I've assumed the directory you want to remove is
C:\Share\
The batch file should look something like this:
del /s /f /q
will recursively search through the directory tree deleting any files (even read only files) without prompting for confirmation.The second line loops through all the sub directories (which should now be empty) and removes them.
Short of deleting the entire folder and recreating it (which I don't think you want to do due to permissions?) this should be the easiest way to clean the folder out.