Generator
asked on
Delete Long Name Files
We have a Windows 2008 Storage Server Standard edition. There are a number of PDF files I would like to delete. When I try to remove them I get a pop up indicating that the file name is too long and must be renamed and then deleted - cannot do either. Also tried the DOS route (Run as Administrator) but get the same error message. Any help would be appreciated.
ASKER
This file is buried under 9 subfolders on a storage server - going to be difficult to use your method. Appreciate the feedback.
Still possible.
subst q: f:\folder1\folder2\folder3 \folder4\f older5\fol der6\folde r7\folder8 \folder9
In the diagram above I've got a long folder path in Explorer's address bar. You can cut and paste that into Notepad. Put quotation marks around the path and use
subst q: "Explorer path"
where Explorer path is the cut and paste.
Save the file as a batch file and run it.
subst q: f:\folder1\folder2\folder3
In the diagram above I've got a long folder path in Explorer's address bar. You can cut and paste that into Notepad. Put quotation marks around the path and use
subst q: "Explorer path"
where Explorer path is the cut and paste.
Save the file as a batch file and run it.
Try this. Rather than renaming the file name, shorten the path where your file is.
So insted of C:\a very long folder\anotherone\the toolongfile.txt
change it to : C:\a very long folder\1\the toolongfile.txt
Then, you should be able to sither rename your file, move it or delete it.
So insted of C:\a very long folder\anotherone\the toolongfile.txt
change it to : C:\a very long folder\1\the toolongfile.txt
Then, you should be able to sither rename your file, move it or delete it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is how you can do it programmatically... If you have Office (Excel, Word) you can use a Macro...
'// Usage
DeleteFile "c:\long path to file here\somefile.txt"
Option Explicit
Private Declare Function DeleteFileW Lib "Kernel32" (ByVal lpFileName As Long) As Long
Private Declare Function RemoveDirectoryW Lib "Kernel32" (ByVal lpFileName As Long) As Long
Public Function DeleteFile(ByVal filePath As String) As Long
DeleteFile = DeleteFileW(StrPtr("\\?\" & filePath))
End Function
Public Function DeleteDirectory(ByVal dirPath As String) As Long
DeleteDirectory = RemoveDirectoryW(StrPtr("\\?\" & dirPath))
End Function
ASKER
I would like to only delete a pdf file not a folder. The other methods mentioned above have not been successful. I have tried the Cancopy program but the file is not visible in the delete window.
Dont delete the folders. Just rename them shorter temporarly. And then once you delete your PDF, rename it back yo what it was. It did work for me.
Thanks.
~bp
~bp
f:\folder_path\
Try at the command line
subst q: f:\folder_path
Then use Windows Explorer to access q: and try deleting. Once deleted then at the command line
subst q: /d