"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message news:<2J********************@comcast.com>...
Hi, I have a code to copy/move folders to a specified folder on the
root drive - ie c:\stuff However, I also have the folder "stuff" on
the root of other partitions as well - ie d:\stuff, e:\stuff, etc.
I would like the code to work so that the selected folder for
moving/copying will always go to the "stuff" folder of the drive that
it is on. In other words, if a folder is selected on the d drive, it
will be moved to d:\stuff, if it's on the c: drive, it will be moved
to c:\stuff.
The way the code is now, the path of the destination folder must be
stated specifically in the code.
And the way it works is a browse for folder dialogue comes up to
select the folder to be copied or moved, and after clicking ok, the
move or copy is made, but always to c:\stuff.
Take the 3 left characters from the Folder Path returned by your "Browse for
Folder Dialogue" routine and concatenate the know folder name "stuff" onto
it...
SaveTo = Left$(FolderReturnedByFolderDialog, 3) & "stuff"
Rick - MVP
I have a problem along the same lines in a way.
I have common named folders on all drives too ( c:\storage,
d:\storage, and so on) and in each folder there are various other
folders all commonly prefixed and suffixed, like abcProject123,
abcDocs123, and so on.
I am trying to create a button a form that when clicked will bring up
an Input box asking to enter the name of a folder to be retrieved
(moved) from whatever Storage folder it is in. So if user enters Docs
and clicks OK, abcDocs123 is moved and renamed to the root of the same
drive the folder stored on.
In other words, if abcDocs123 was in E:\Storage, it would be moved to
E:\Docs.
Presently, I have the problem partially solved using dos-vbs in a bat
file which can be called by the shell function:
echo fn=InputBox("Enter folder name. ","Folders")>%TEMP%.\FN.VBS
echo wscript.echo "SET FN="&fn>>%TEMP%.\FN.VBS
cscript //nologo %TEMP%.\FN.VBS>%TEMP%.\FN.BAT
CALL %TEMP%.\FN.BAT
for %%a in (c: d: e: f: g: h: i: j: k:) do if exist
"%%a\storage\abc%FN%123\NUL" move "%%a\storage\abc%FN%123" "\%FN%"
What the above does:
brings up an Input box, a folder name is entered, and the folder is
found in whatever drive it is in (c: to k:) The problem is that it
can't move the found folder unless that folder is on the same drive as
the bat file is run from.
So if the bat file is run from the c: drive, only folders found in
c:\storage will be moved to c:\ Move cannot move accross drives but
if VB can make the code so that the found folder will be moved to the
root of whatever drive it is on, then move can always be used and it
would be acceptable and better than using dos-vbs. thanks for any
help!
jenn