I am using a shell to delete pdf files after they have been processed by the app. I just saw a pdf file that would not delete using this shell command. The filename has = in the filename. If I remove the = then it will delete it. I don’t see where = is not supposed to be used in a windows file name. Also file name with parentheses in the name like (1).pdf will not delete.
Is there a command that will delete the file no matter what the name is?
e = "del " + sourcefile.ShellPath
s.execute(e)
Try
e = "del " + String.ChrByte(34) + sourcefile.ShellPath + String.ChrByte(34)
s.execute(e)
I will give that a try.
Thanks Wayne
That did not work. The file with = in the name was not deleted.
Thanks for the try.
Does sourcefile.remove
work?
Yes that worked perfectly.
Thanks
Sourcefile.remove will not always remove the file (for example if it used).
This will work always without escaping special chars:
e = “ del " + Chr(34) + sourcefile.nativepath + Chr(34)
s.execute(e)
Is it preferable to use nativepath in a shell command?
I was under the impression that we should use shellpath.
Some chars are not escaped when using shellpath (at least when running Windows). Using nativepath and quotes, it does always work.
Can you provide more information? This would be a major bug worth reporting if true.
1 Like
It is no bug. Some chars cannot be escaped. That’s how it is.
This does fix the issue. I was also having problems with a space in the filename and this fixed it.
Thanks
That doesn’t apply to filenames, folder names, or any local (non-network) resource.
Well, it does for sure for several chars. Especially if you going from macOS to Windows (macOS allows far more special chars for filename/folders/…
These are not allowed in Windows but are in macOS: < > " / \ | ? *
If you use shellpath, it will not work. Using nativepath (with quotes) it will work fine.