Shell COMMAND.COM + multiple commands

ajm59

New member
Local time
Today, 10:44
Joined
Nov 8, 2005
Messages
4
Dear All,

as first let me say that I am NOT an expert programmer and I use to prepare some applications for my personal usage.

Now let's go to the point.

By means of a push button I want to rename and move some JPG files, which are normally located in different directories & subdirectories, depending on the values of two text fields present in a main form. In other terms, changing the values of such fields, I need that the file names and their directories change accordingly.
So I was thinking to launch SHELL "COMMAND.COM" and then send to the command line the needed DOS commands by means of SendKeys, but it does not work.
At last, I cannot prepare a .BAT file to perform the whole job, as the names of the directories are variable and determined by the values selected in the Access form.
Can you suggest me how can I send several commands on the DOS screen after I opened in with the SHELL ? Different solutions to my problem are certainly welcome. Thanks. Alberto
 
Alberto,

you can move files from one directory to another, like this:
Code:
dim fso as object

set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "C:\olddir\*.jpg", "c:\newdir"
the above would move all jpeg files to the newdir.

If you are talking about renaming and moving a single file, try this:
Code:
dim fso as object

set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "C:\olddir\oldfilename.jpg", "c:\newdir\newfilename.jpg"

If neither of those fits your needs exactly, look up FileSytemObject on the Microsoft MSDN site.

HTH,
Chris
 
you can directly rename a file in access with the

name command

this includes changing the path (not sure if it deletes if you are moving volumes), and it wont overwrite a file
 
Hi Chris,
just wanted to thank you as I solved my problem thanks to your suggestion. I had never used so far the FSO model. There is a plently of good functions to utilize.
Bye.
 

Users who are viewing this thread

Back
Top Bottom