Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

writing a macro to copy files to new folder


16 replies to this topic

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 02:00

Hi again,

My next dilemna is how to write a macro to copy files from multiple folders to a new folder on the harddrive....any suggestions?

Thanks

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 29 July 2004 - 04:39

Sounds like a regular batch file with xcopy should do the trick?
Regards
-Stein Åsmul

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 05:27

Oh forgot to mention I am not a programmer so if possible can you be more specific ;-) ie: I have no idea where or how to write a batch file.

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 05:52

Well, some of my ancient dos is coming back....here's what I'm trying to do and I know the individual copy command but how can I get it to automatically go through each folder and only copy the files[not folders] to the cd?

Here's what I know so far ;-)

cmd
copy c:\test\disk1\*.* g:
that works
now I have to do the same for each of the following:
c:\test\disk2\*.* g:
c:\test\disk3\*.* g:
c:\test\disk4\*.* g:
c:\test\disk5\*.* g:
c:\test\disk6\*.* g:
is that what the batch file will do?

then there are a couple of single files that need to also be copied. The next step is trickier, I have 36 individual folders that each have one client specific file that needs to be copied onto the cd. Each one is in a specific client named folder, can i get it to prompt me to put in client1 cd, then client2 cd, etc?

I learning...thanks

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 06:32

This is just an aside question. How can I see the entire file name and extension in xp. Sure it shows the name and then I choose type but I would prefer to see the extension. Any thoughts. Thanks

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 29 July 2004 - 07:09

Use xcopy to copy files and directories (including sub directories) in a batch file. Type xcopy /? in your command line editor for a list of switches (to get a command line editor press start : run : type "cmd" : press enter).

To show file extensions in XP, open Windows Explorer. Tools : Folder Options... : View : Uncheck "Hide extension for known file types".
Regards
-Stein Åsmul

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 13:20

Thanks!!

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 13:30

Great extensions again ;-)

Just to clear my confusion, a batch file is first written in notepad and saved as a .bat file ? And should it be in aspecific location on my harddrive or is any directory fine?



Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 29 July 2004 - 14:46

Yes, write it in Notepad. If you are on XP you can call the file *.cmd or *.bat. if you hard code the folder paths the batch should be usable from anywhere on your computer, with the major drawback that you cannot move any files without breaking your batch file. You can make the script more flexible using relative paths: copy /folder/file.txt ../../file.txt. If you use relative paths, the batch file must be in the correct folder relative to the files you want to copy. Hope this made sense, it is late here in Sydney smile.gif.

Edited by Glytzhkof, 29 July 2004 - 14:47.

Regards
-Stein Åsmul

believer

believer
  • Members
  • 17 posts

Posted 29 July 2004 - 21:29

Sorry about the lateness!! wanted to update you on my success....wrote the following batch file and it's working - whew hew....the DOS does come back, thank you for the initial push.

@ECHO OFF
:LOOP

echo MPT Full install file transfer from Disk1-Disk6
md D:\makecd\setup\FULL
copy setup\disk1\*.* D:\makecd\setup\FULL
copy setup\disk2\*.* D:\makecd\setup\FULL
copy setup\disk3\*.* D:\makecd\setup\FULL
copy setup\disk4\*.* D:\makecd\setup\FULL
copy setup\disk5\*.* D:\makecd\setup\FULL
copy setup\disk6\*.* D:\makecd\setup\FULL
echo

echo copy autorun.inf
copy setup\autorun.inf D:\makecd\setup\FULL
echo

echo delete setup.inf
del setup\full\setup.inf
echo

echo MPT Full install
echo Insert CD labeled CD FULL
pause
label G: MPT FULL INSTALL
copy D:\makecd\setup\FULL\*.* G:
echo

if not exist setup\disk7.* goto NOCD

:NOCD
echo Hit CTR-C if no more CDs are needed
pause
goto :LOOP

believer

believer
  • Members
  • 17 posts

Posted 30 July 2004 - 03:22

Hello Sydney ;-)
I'm getting better but have a couple of questions you might be able to answer.

I will describe what I need to do in layman's terms:

assumptions:
my CD drive is G
I know what I'm doing - hee hee

I have the following directory on my D: drive
d:\sites\client1
d:\sites\client2
d:\sites\client3
d:\sites\client4
etc

each client folder contains the same named file[diferent contents specific to that client]

I would like to write a batch file that will echo "insert CD for Client1"
then go to the d:\sites\client1 folder and copy fileX to the CD and overwrite if that file is found on the CD
eject CD

then automatically scroll to the next folder [client2] and echo "insert CD for Client2"
then go to the d:\sites\client1 folder and copy fileX to the CD and overwrite if that file is found on the CD
eject CD

then the same for Client3, client4, etc..

any ideas on the commands that will look at the folder name and prompt for that name and then copy to cd, eject cd and auto scroll to next folder in the directory tree and prompt for that name and then copy to cd, eject cd and auto scroll to next folder in the directory tree etc...

Thanks for any and all ideas...please remember i am a beginner ;-)

Considering the time, I understand you're probably eating some "shrimp on the barbee" -- just kidding

Thanks again


Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 30 July 2004 - 08:06

Sorry, but I don't understand this. It is generally not possible to write to a CD on the fly unless you mount a disk with a program designed to do this transparently.
Regards
-Stein Åsmul

believer

believer
  • Members
  • 17 posts

Posted 30 July 2004 - 13:18

Hi,

I am able to write directly to the CD because it is a CD-RW and I go through the 25minute process of formatting it. Then it can be used just like a floppy. So I just format several disks beforehand.

Thanks again.

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 30 July 2004 - 13:34

So what you want is to create a bunch of CD-releases? If so you could create one version of each CD, create an ISO image of the CD and then burn the image onto each new CD.

Regards
-Stein Åsmul

believer

believer
  • Members
  • 17 posts

Posted 30 July 2004 - 15:30

Thanks sounds faster for sure, however the one catch is there is 1 file that is unique. So I think I have to do each individualy.

ps: what is an ISO image?

Have a great day!!

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 31 July 2004 - 13:53

An ISO image is the contents of a CD compressed into a standard format (single file) that can be written back to CD using a CD-burner tool. If there is a single file that is different on the CD for each user you can't use this approach.

I have limited experience with batch files, but you should be able to use the pause command to suspend batch file processing after a CD has been created. You can also launch commands with start /wait [command] or cmd.exe /c [command] may also work. You would then need to press a key to continue processing after the CD has been inserted.

Edited by Glytzhkof, 31 July 2004 - 13:54.

Regards
-Stein Åsmul

believer

believer
  • Members
  • 17 posts

Posted 31 July 2004 - 14:24

Thanks for the information, will try. have a great day!