[SOLVED] Cannot delete file with a long name ?

Status
Not open for further replies.

Pimpom

Distinguished
May 11, 2008
468
31
18,940
I saved a webpage as a pdf file on my Desktop and now cannot delete it. The file name by itself is 251+3 characters long but the path makes it much longer.

The filename is "SanDisk Extreme SD ............ .pdf". I used CMD with the command "dir /x" to generate 8+3 filenames for all files on the Desktop. It did it correctly for all files and folders EXCEPT for the problem file. The resultant short name is simply "SAN" without an extension, not the expected "SanDis~1.pdf". I tried to delete that but the system couldn't find it.

As suggested somewhere, I tried to rename it in 7-zip but my 7-zip (v22.01 x64) doesn't seem to have that option.

Any suggestions please?
 
Solution
I got it...

C:\Users\GardenMan\Desktop>del "\\?\C:\users\gardenman\desktop\SanDisk Extreme SD UHS I 32GB Card for 4K Video for DSLR and Mirrorless Cameras 100MB_s Read & 60MB_s Write - Buy SanDisk Extreme SD UHS I 32GB Card for 4K Video for DSLR and Mirrorless Cameras 100MB_s Read & 60MB_s Write Online at Low Price in India .pdf"

Be sure to add that space before ".pdf".

Pimpom

Distinguished
May 11, 2008
468
31
18,940
I already did before posting here. It failed too. The difference from CMD is that PowerShell rejects the /x attribute to create 8+3 filenames.

I just tried it again with the long filename. It gave an error message saying the ampersand character & (which is present in the long filename) is not allowed. It told me to wrap it in double quotes to make it a part of the string. It makes no difference. It ignores the wrap inside "" and the same error message keeps coming up.

The wrap probably doesn't work because I'm applying it to an existing filename.
 
Last edited:

Pimpom

Distinguished
May 11, 2008
468
31
18,940
I saved the page as a pdf file, not html, while viewing a customer's review image at Amazon.in (India). The URL is
https://www.amazon.in/SanDisk-Extreme-Video-Mirrorless-Cameras/dp/B09ZS1PHV4?th=1

I use Chrome v109. Amazon doesn't let me save review images directly, so I usually capture a screenshot when I want to examine an image in detail. This time, however, I used the "Print" option to save it as a pdf file. The pdf file opens normally with a reader. I saved it "as is" without altering anything.
 
Last edited:
D

Deleted member 14196

Guest
Just do del
Then just start with a few first letters and hit the tab key and it should finish the name of the file for you and then delete it

if you install git for windows, you’ll have a bash shell you can run the Linux remove command on it

rm -f filename

you can still use the same track with just starting to spell the file name and then hit the tab key to do name completion
 

gardenman

Splendid
Moderator
I'm trying to delete it also on a test system. I am NOT the OP, just trying to figure it out.

That doesn't work Mandark, I just tried it.

Here's a few other attempts I've tried so far:
gZU2nVo.jpg
 

gardenman

Splendid
Moderator
I got it...

C:\Users\GardenMan\Desktop>del "\\?\C:\users\gardenman\desktop\SanDisk Extreme SD UHS I 32GB Card for 4K Video for DSLR and Mirrorless Cameras 100MB_s Read & 60MB_s Write - Buy SanDisk Extreme SD UHS I 32GB Card for 4K Video for DSLR and Mirrorless Cameras 100MB_s Read & 60MB_s Write Online at Low Price in India .pdf"

Be sure to add that space before ".pdf".
 
Solution

Pimpom

Distinguished
May 11, 2008
468
31
18,940
I did. I was careful about that. It didn't make any difference.

Thanks for the efforts, guys. It's 3 am here and I have to get some sleep. Will pick up again tomorrow.
At least it's apparently not some stupid thing I did.
 

Pimpom

Distinguished
May 11, 2008
468
31
18,940
That works. Thanks a lot.
Before following your instructions exactly, I tried it with slight variations to see what happens. None of them works.
  1. Without the quotation marks
  2. With quotation marks but without typing the whole path since it was already in the same directory (Desktop)
and a couple of others.

Could you explain just what \\?\ does? I'm just an end user.
 
Status
Not open for further replies.