Browsing for directory

I have the need to be able to browse for a directory on a CF page in order to pass that directory to a <cffile> tag. I tried using a form with <input type=“file”> but that just seems to pass the file name with nothing else, so #GetDirectoryFromPath()# has no effect.

Is there any good way to pass a directory name to this tag without having to type it in?

how about through a url variable? I don’t understand what you were doing with the file input tag and how you got the directory name into that field.

I don’t really understand what you’re trying to do here. Browse a directory located where… on the server?

  1. <input type=“file” …> works with files on the user’s computer. Plus it doesn’t work with directories. It submits a single file to the server

  2. cffile works on the server. So even if you could submit a directory, it’s not a directory on the server, and obviously cffile works with files, not directories.

So I’m confused. Can you clarify your goal for us? :wink:

Sorry about that. I guess I should have included a bit more detail.

We have a web development server that all our web pages sit on. It’s mapped as a drive letter to us, and we go in using Windows Explorer and copy, paste, etc to move files around.

The security people have declared that we will no longer have access to the server via Explorer (don’t ask me why, because even they aren’t sure), and have instead set us up with some sort of fancy software that creates a secure connection. Keep in mind that this server is only accessible to people who are physically inside the building (which you need a security clearance to enter) and who have access (username/password) to get onto a computer, and who have been granted access rights to the development server to begin with.

Anyway… the fancy new software does pretty much everything we need. Except for batch-renaming files. You have to do them one by one.

Since we’re in the middle of redesigning our entire website, we occasionally have the need to be able to batch rename files, especially since we’ve been copying the old HTML files to the new directory, then batch-renaming them to have a .cfm extension, then opening them up and applying the new template to the existing content. We’re talking thousands of files, so to rename them one-by-one is a bit… time consuming.

So, I built a script that uses <cffile> to batch-rename the files. The initial version just looks at the current directory, so that means we have to copy the thing to where the target files are before running it. I was hoping to have one that lived on the root of the development server (which we would bookmark) that we could use to browse for the folder we needed to do the rename on.

Hope that makes some sort of sense.

Well if you don’t have windows explorer access, you’ll have to build your own. Create a page that does a cfdirectory on the root. Then displays the subfolders as links back to the same page. Pass the subdirectory path as a link parameter. Then use that value to do another cfdirectory. That’ll let you drill-down or drill-up through the directory tree.

Hey, that’s a really good idea. I’ll experiment with that tomorrow.