Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename a Folder from a form variable?!? 2

Status
Not open for further replies.

Cirrus9

IS-IT--Management
Aug 21, 2001
248
US
I am copying a new folder from a master and I need to rename it based on a variable passed from a form. I have checked and I am passing the variable just fine. I am also able to create the folder just fine using fso.copyfolder. I can only copy it to predetermined name so......

1) Can I create a new folder using the fso.copyfolder method and have it use a variable for a name?
ex. fso.copyfolder "C:\oldfolder","C:\formvariable"

or if that won't work,

2) Can I first create the folder and then rename it based on a variable I passed from a form?

or if that won't work,

What will?

Thanks for your help in advance.

 
i think you can do the first option without any problems...

something like this...

foldername=request.form("fname")
myfolder="c:/"&foldername

then

set f= fso.createfolder(myfolder)

-DNG
 
Oh, and you want to make sure you remove all the invalid characters... the ones that cannot appear in a filename like "*" and "\" ... I think there at least half a dozen of them...
 
Thanks DotNetGnat & Sheco,
I found the problem. I was focusing on the processing page and not the form page. I as using the Get method for the form instead of the post.(Simple Oversight,Dumb mistake)

However, I used

<%
foldername=request.form("Fname")
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder "C:\Master","C:\"&foldername
Set fso=Nothing
%>

It works great
Thanks again!

 
but dont ignore the point mentioned by Sheco...what if one of your user enter the Fname as blah\blah.*

so to avoid these...please check for Regular Expressions...i mean the Regex() function...

-DNG
 
I have a form validation I am finishing. I have a string cleaner I will use for it.

Thanks again
 
that sounds great...you can share your string cleaner function here if you want so that someone can use it if needed...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top