forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


VDS Dir/File Copy Routine...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Jun 23, 2002 7:02 am    Post subject: VDS Dir/File Copy Routine... Reply with quote

This is a dir/file copy routine that keeps the dir structure
intact, much like DOS "XCOPY". It copies hidden, system
and read-only dirs and files.

Be aware that VDS "FILE COPY" will not copy some
IE bookmarks correctly (the ones that IE adds, such
as "Channels", etc.). Otherwise it seems to work OK.

Change the %%source and %%target vars for your use.
Code:

rem -- The target dir --
%%target = "C:\TestDir"

rem -- The source dir --
%%source = "C:\Multimedia Files"

LIST CREATE, 1, SORTED

rem -- Load Dir/SubDir list (including hidden, system, and read-only) --
LIST FILELIST, 1, %%source, *DHSR

%x = 0
REPEAT
  rem -- Get subdir name without root dir --
  %%subdir = @item(1, %x)
  %p = @pos(%%source, %%subdir)
  if @greater(%p, 0)
     %%subdir = @strdel(%%subdir, 1, @sum(%p, @len(%%source)))
  end
  rem -- Create subdirs in target dir and copy files --
  DIRECTORY CREATE, %%target\%%subdir
  FILE COPY, @item(1, %x)\*.*, %%target\%%subdir, SHOWERRORS
  %x = @succ(%x)
UNTIL @equal(%x, @count(1))@greater(%x, @count(1))

rem -- Add root dir files to target dir --
FILE COPY, %%source\*.*, %%target, SHOWERRORS

INFO Finished!


Cheers, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Nov 28, 2002 4:25 pm    Post subject: Reply with quote

Hi Mac

I'm turning your code into a subroutine that will copy only specific file types. Two questions! Why do you need the conditional that tests to see if the subdirectory is present in the source? I cannot see when it would not be! Secondly the code creates all the directory structure even if it has no files that need copying, could it easly be modified to only create directories that have files.

Code:

rem -- The target dir --
%%target = @input(target)

rem -- The source dir --
%%source = @input(source)

%%list_no = @input(list)

%%extn = @input(extn)

:xcopy
LIST CREATE, %%list_no, SORTED

rem -- Load Dir/SubDir list (including hidden, system, and read-only) --
LIST FILELIST, %%list_no, %%source, *DHSR

%%xcopy_index = 0
REPEAT
  rem -- Get subdir name without root dir --
  %%subdir = @item(%%list_no, %%xcopy_index)
  %%xcopy_pos = @pos(%%source, %%subdir)
  if @greater(%%xcopy_pos, 0)
     %%subdir = @strdel(%%subdir, %%list_no, @sum(%%xcopy_pos, @len(%%source)))
  end
  rem -- Create subdirs in target dir and copy files --
  DIRECTORY CREATE, %%target\%%subdir
  FILE COPY, @item(%%list_no, %%xcopy_index)\*.%%extn, %%target\%%subdir, SHOWERRORS
  %%xcopy_index = @succ(%%xcopy_index)
UNTIL @equal(%%xcopy_index, @count(%%list_no))@greater(%%xcopy_index, @count(%%list_no))

rem -- Add root dir files to target dir --
FILE COPY, %%source\*.%%extn, %%target, SHOWERRORS
%%target =
%%source =
%%extn =
%%subdir =
%%xcopy_index =
%%xcopy_pos =
list close,%%list_no
:exit



Thanks

David Monckton
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Nov 28, 2002 4:40 pm    Post subject: Reply with quote

__________________________________________________________________________________________________________________________
Checking if the directory exists was just a safety
measure in case the user (or another program)
removes it while the program is running. Not
likely, but possible when copying large dir
structures with lots of files.

It copies empty dirs to keep the directory structure
intact (as mentioned in the description). This was
what I wanted, but you should make any necessary
changes to suit your needs. Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group