Skip to main content
Nov 9, 2012 6:08 PM UTC
Question

How to delete files with backslash in name

I had some code that was developed for a windows server to create some image files. The destination parameter had backslashes in the path. When run on a Coldfusion 9  linux server, the files ended up in the top directory with long filenames consisting of ' directory\directory\filename'.  Now I need to delete them. I've tried cffile action="delete" file="directory\\directory\\filename">.

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

johnvalter88
Participant
Aug 2, 2019 10:02 PM UTC

The Longpathtool is the very best program for error, unlock solution. Try it and solved your problem. I used the long path tool and I solved my error, unlocks problem solution.

Translate
BKBK
Community Expert
Community Expert
Nov 11, 2012 9:11 PM UTC

The syntax is <cffile action="delete" file="absolute_path_to_the_file">. So what you need to do is figure out how to get the absolute path, on the basis of the current page.

Translate
WolfShade
Legend
Sep 19, 2016 1:58 PM UTC

ExpandPath() should work.

V/r,

^_^

Translate
Inspiring
Nov 11, 2012 2:40 PM UTC

Did just deleting them exactly as-is (ie: without escaping the backslashes) not work?

--

Adam

Translate
Inspiring
Nov 10, 2012 2:01 PM UTC

Execute cfdirectory on the directory in question.  Loop through the query object and use whatever field refers to the name of the file.  I'd have to look that up, but you can do that.

Translate