Header Ads

Header Ads

Deleting Invalid or too long folders and files on Windows

Hi, there! Everyone have such problems as "unable to delete files or folders" it can be reason of invalid file names or too long path. Today i will write a few tips to cover it and deal with it. So you now can easily remove any unnecessary data from your Windows PC. First of all make sure you have checked all your partitions for errors with command "chkdsk /V /f <disk>" for example.: "chkdsk /V /f d:".

There are a little registry tweak, it will add an option called "Delete invalid files" to every directory context menu.

Windows Registry Editor Version 5.00
@="Delete invalid files"
@="cmd.exe /c RD /S \"%1\""
"IsolatedCommand"="cmd.exe /c RD /S \"%1\""

Save this text as del_invalid_files.reg and double click on it to apply the tweak. Another tweak is for deleting long pathnames. First you need to make del_long_path.cmd and paste this text to it!

@echo off
if _%1_==__ (
echo Usage: %0 folderpath
echo Deletes specified folder and all subfolders, even if the path depth
echo is larger than what CMD/Explorer will manage.
echo folderpath - the folder to delete
goto end
set target_folder="%~f1"
set target_drive=%~d1
set tmp=%3
set del_temp_folder=nope
if {%tmp%}=={} set tmp=%target_drive%\temp_%RANDOM%
if not exist %tmp% (
md %tmp%
echo Will delete folder: %target_folder%
echo Will use temp folder: %tmp%
set del_temp_folder=yepp
set i=%2
if {%i%}=={} set i=0
set /A i=%i% + 1
echo Level %i%, folder %target_folder%
del /Q /F %target_folder%\*
for /D %%d in (%target_folder%\*) do (
move "%%d" "%tmp%\%i%_%%~nd"
rd /Q %target_folder%
for /D %%d in (%tmp%\%i%_*) do (
call %0 "%%d" %i% %tmp%
rem ** Clean upp
if {%del_temp_folder%}=={yepp} (
rd /Q %tmp%

Save it and copy to Windows\system32 folder. Next create del_longpath.reg and paste this text to it!

Windows Registry Editor Version 5.00
@="Delete longpath"
@="cmd.exe /c del_long_path.cmd \"%1\""
"IsolatedCommand"="cmd.exe /c del_long_path.cmd \"%1\""

As you see you the option "Delete longpath" will appear on your directory context menu. Double click on it apply and enjoy! :-)

1 comment:

  1. If you are finding problems related to long pat files or folder, try using Long Path Tool, it works greatly..


Copyright (c) 2012-2013 Unix Master. Powered by Blogger.