| View previous topic :: View next topic |
| Author |
Message |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Tue May 13, 2003 12:37 am Post subject: Knot-head - really needs help ... |
|
|
Would really like to apologize for my attitude and perhaps start over - I am just very bull-headed and get frustrated when something like this makes me feel no smarter than a knot-head. So to all those kind enough to help me before - thank you and hope we can start a new. If not understood
I am attempting to create a list of all sub-dir & files from %%path (no root files), such as in example1. Why when I attempt to create the list from within %%path in example 2, as to remove the path from the list, it does it not work? - Any ideas what I am doing wrong - seems so simple yet it does not work??
(edited (working now))
Example 1:
| Code: | :LR
REM -- LIST ALL FILES IN THE ROOT OF A DIRECTORY
LIST CREATE, 1
LIST CREATE, 2
LIST CREATE, 3
LIST CREATE, 4
%%PATH = "C:\TEMP"
DIRECTORY CHANGE,%%PATH
LIST FILELIST, 1, *.*
LIST FILELIST, 2, *.*, SHR
%X = 0
REPEAT
IF @GREATER(@COUNT(1), %X)
LIST ADD, 3, @ITEM(1, %X)
END
IF @GREATER(@COUNT(2), %X)
LIST ADD, 3, @ITEM(2, %X)
END
%X = @SUCC(%X)
UNTIL @BOTH(@GREATER(%X, @COUNT(1)), @GREATER(%X, @COUNT(2)))
LIST ASSIGN, 4, 3
INFO Finished - @COUNT(4) files found at the root of %%PATH ...
%%REPORT = C:\ROOT.TXT
IF @FILE(%%REPORT)
FILE DELETE, %%REPORT
END
LIST SAVEFILE, 4, %%REPORT
RUN %%REPORT
LIST CLEAR, 1
LIST CLEAR, 2
LIST CLEAR, 3
LIST CLEAR, 4
EXIT
|
Example 2:
| Code: | :LS
REM -- LIST ALL SUB-DIRECTORIES AND FILES OF A DIRECTORY (NO ROOT)
LIST CREATE, 1
LIST CREATE, 2
LIST CREATE, 3
LIST CREATE, 4
LIST CREATE, 5
%%PATH = "C:\TEMP"
LIST FILELIST, 1,%%PATH, *D
%X = 0
REPEAT
IF @GREATER(@COUNT(1), %X)
LIST FILELIST, 2, @ITEM(1, %X)
LIST FILELIST, 3, @ITEM(1, %X), SHR
END
%Y = 0
REPEAT
IF @GREATER(@COUNT(2), %Y)
LIST ADD, 4, @SUBSTR(@ITEM(2,%Y),@SUCC(@LEN(%%Path)),@LEN(@ITEM(2,%Y)))
END
IF @GREATER(@COUNT(3), %Y)
LIST ADD, 4, @SUBSTR(@ITEM(3,%Y),@SUCC(@LEN(%%Path)),@LEN(@ITEM(3,%Y)))
END
%Y = @SUCC(%Y)
UNTIL @BOTH(@GREATER(%Y, @COUNT(2)), @GREATER(%Y,@COUNT(3)))
LIST CLEAR, 2
LIST CLEAR, 3
%X = @SUCC(%X)
UNTIL @GREATER(%X, @COUNT(1))
%X = 0
REPEAT
IF @GREATER(@COUNT(4), %X)
LIST ADD, 5, @ITEM(4, %X)
END
%X = @SUCC(%X)
UNTIL @GREATER(%X, @COUNT(4))
INFO Finished - @COUNT(5) files found at %%PATH - Not including root files ...
%%REPORT = C:\SUB2.TXT
IF @FILE(%%REPORT)
FILE DELETE, %%REPORT
END
LIST SAVEFILE, 5, %%REPORT
RUN %%REPORT
LIST CLEAR, 1
LIST CLEAR, 2
LIST CLEAR, 3
LIST CLEAR, 4
LIST CLEAR, 5
EXIT
|
Last edited by spOOk on Wed May 14, 2003 3:14 am; edited 3 times in total |
|
| Back to top |
|
 |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Tue May 13, 2003 5:55 pm Post subject: Well this is what I have came up with ... |
|
|
This is what I ended up coming up with ... | Code: |
:LS
REM -- LIST ALL FILES & SUB-DIRECTORIES OF A DIRECTORY (PATH REMOVED)
LIST CREATE, 1
LIST CREATE, 2
LIST CREATE, 3
LIST CREATE, 4
LIST CREATE, 5
%%SRC = "C:\TEMP"
REM -- LOAD ROOT FILES
LIST FILELIST, 1,%%SRC
LIST FILELIST, 2,%%SRC, SHR
%X = 0
REPEAT
IF @GREATER(@COUNT(1), %X)
LIST ADD, 3, @SUBSTR(@ITEM(1,%X),@SUCC(@LEN(%%SRC)),@LEN(@ITEM(1,%X)))
END
IF @GREATER(@COUNT(2), %X)
LIST ADD, 3, @SUBSTR(@ITEM(2,%X),@SUCC(@LEN(%%SRC)),@LEN(@ITEM(2,%X)))
END
%X = @SUCC(%X)
UNTIL @BOTH(@GREATER(%X, @COUNT(1)), @GREATER(%X, @COUNT(2)))
LIST ASSIGN, 5, 3
LIST CLEAR, 1
LIST CLEAR, 2
LIST CLEAR, 3
REM -- LOAD SUB-DIRECTORIES & FILES
LIST FILELIST, 1,%%SRC, *D
%X = 0
REPEAT
IF @GREATER(@COUNT(1), %X)
LIST FILELIST, 2, @ITEM(1, %X)
LIST FILELIST, 3, @ITEM(1, %X), SHR
END
%Y = 0
REPEAT
IF @GREATER(@COUNT(2), %Y)
LIST ADD, 4, @SUBSTR(@ITEM(2,%Y),@SUCC(@LEN(%%SRC)),@LEN(@ITEM(2,%Y)))
END
IF @GREATER(@COUNT(3), %Y)
LIST ADD, 4, @SUBSTR(@ITEM(3,%Y),@SUCC(@LEN(%%SRC)),@LEN(@ITEM(3,%Y)))
END
%Y = @SUCC(%Y)
UNTIL @BOTH(@GREATER(%Y, @COUNT(2)), @GREATER(%Y,@COUNT(3)))
LIST CLEAR, 2
LIST CLEAR, 3
%X = @SUCC(%X)
UNTIL @GREATER(%X, @COUNT(1))
%X = 0
REPEAT
IF @GREATER(@COUNT(4), %X)
LIST ADD, 5, @ITEM(4, %X)
END
%X = @SUCC(%X)
UNTIL @GREATER(%X, @COUNT(4))
INFO Finished - @COUNT(1) folders & @COUNT(5) files found at %%SRC ...
%%REPORT = C:\FILES.TXT
IF @FILE(%%REPORT)
FILE DELETE, %%REPORT
END
LIST SAVEFILE, 5, %%REPORT
RUN %%REPORT
LIST CLEAR, 1
LIST CLEAR, 2
LIST CLEAR, 3
LIST CLEAR, 4
LIST CLEAR, 5
EXIT
|
On to the next step - retrieve the file information - clueless
Last edited by spOOk on Wed May 14, 2003 3:10 am; edited 4 times in total |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue May 13, 2003 7:13 pm Post subject: |
|
|
You might check into the VDSDLL3.DLL for listing all subdirectories
and files below a source and you can mask it too.
Download the VDSDLL3.DLL at:
http://www.vdsworld.com/index.php?page=download&fileid=60
Besides containing that function it also contains an excellent set of other
functions, commands, and possibilities.
However, if you want to check file information, look into the @file()
function. You can retrieve a lot of different information on a file with this.
I hope this helps.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Tue May 13, 2003 8:35 pm Post subject: thanks |
|
|
Thanks for posting
Will look into VDSDLL3.DLL, as this seems awfully long away around to just to be able to compare various file information from - what will initially be from multiple directories...
input is greatly welcomed .... |
|
| Back to top |
|
 |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Tue May 13, 2003 11:33 pm Post subject: |
|
|
Hey FF
Will I need to retrieve time/date info and store it in the lists then do a comparison of the lists. Or should I retrieving the time/date info and sorting as I am obtaining the all files/sub-dir list then add that info to a list.
Just attempting to find out which would be best avenue to start?
Best Regards |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed May 14, 2003 12:07 am Post subject: |
|
|
If you could re-explain exactly what you are trying to do, that would be
of great help... right now I'm a bit lost as to what you are trying to do.
Here's what I have interpreted is that you want to get a list of files and
their directories below a specified directory. Am I correct?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Wed May 14, 2003 3:04 am Post subject: |
|
|
FF
A BACKUP UTILITY
COPY ALL SOURCE DIRECTORY FILES TO A TARGET DIR. BUT ONLY IF DOES NOT EXIST IN TARGET DIR OR OF SOURCE IS NEWER. BUT FIRST THING I HAD TO DO WAS LEARN HOW TO GET ALL FILES FOR COMPARISON. NOW I AM NOT SURE - MANY IDEAS BUT JUST THAT IDEAS.
HERE IS WORKING EXAMPLE OF SINGLE FILE EXAMPLE (POSTED BY DR DREAD) IF YOU HAVE ANY IDEAS LET ME KNOW
| Code: | rem -- compare source files to destinations - copy if not exist or if newer
%%srcpath = "C:\temp\"
%%srcfile = "autoexec.bat"
%%oldfile = %%srcpath%%srcfile
%%targetpath = "d:\test\"
%%newfile = %%targetpath%%srcfile
directory change,%%targetpath
if @not(@ok())
DIRECTORY CREATE,%%targetpath
end
if @file(%%newfile)
if @greater(@file(%%oldfile,T),@file(%%newfile,T))
file copy,%%oldfile,%%newfile
else
info No new files to copy
end
else
info Existing file not found. Copying now..
file copy,%%oldfile,%%newfile
end
exit |
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed May 14, 2003 5:35 am Post subject: |
|
|
| spOOk wrote: |
Will I need to retrieve time/date info and store it in the lists then do a comparison of the lists. Or should I retrieving the time/date info and sorting as I am obtaining the all files/sub-dir list then add that info to a list.
Just attempting to find out which would be best avenue to start?
|
Hey spOOk!
Here's my suggestions as to a stroll down the avenue
1. Make a list containing all subdirectories to your source dir. Stay with dirs only.
2. Cycle through your list 1 and list all the files in each dir. Make sure you don't miss e.g. hidden files.
3. Step through list 1 again. Check if all the source dirs are present in target - if not create them now.
4. Step through each file in list 2. Check if it's present in target: if not just copy it, if yes then compare with file in
source, and only copy if newer. (Hint: strip source dir part from listed files so only subdirs are left)
I think that should do it.
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Wed May 14, 2003 5:51 am Post subject: |
|
|
Hello
Thank you for informative advice !!
Best Regards |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
|
| Back to top |
|
 |
spOOk Newbie

Joined: 28 Mar 2003 Posts: 21
|
Posted: Tue May 20, 2003 5:22 am Post subject: |
|
|
Thanks everyone - I am slowly moving along
Having real problem with removing the source path completely from my list, which worked ok with root files (Example 1) But attempting to remove the path in (Example 2) is killing me -
Any ideas -
| Code: | %%src = "c:\temp"
%%dest = "d:\test"
directory change, %%dest
if @not(@ok())
directory create, %%dest
end
list create,1
directory change,%%src
list filelist, 1, *.*
%x = 0
repeat
%%file = @item(1, %x)
%%newfile = %%dest\%%file
if @file(%%newfile)
if @greater(@file(%%file, T),@file(%%newfile, T))
file copy,%%file,%%newfile
info Found same name files with newer dates - copying now
else
rem info No new files to copy
end
else
info New file found - copying now
file copy,%%file,%%newfile
end
%x = @succ(%x)
until @equal(%x,@count(1))
%%REPORT = C:\ROOT.TXT
IF @FILE(%%REPORT)
FILE DELETE, %%REPORT
END
LIST SAVEFILE, 1, %%REPORT
RUN %%REPORT
list clear, 1
info Finished!
exit
|
Example 2
| Code: |
%%src = "c:\temp"
%%dest = "d:\test"
directory change, %%dest
if @not(@ok())
directory create, %%dest
end
list create,1, sorted
list filelist, 1, %%src, *DHSR
%x = 0
repeat
%%subdir = @item(1, %x)
%p = @pos(%%src, %%subdir)
if @greater(%p, 0)
%%subdir = @strdel(%%subdir, 1, @sum(%p, @len(%%src)))
end
directory create, %%dest\%%subdir
%%newfile = %%dest\%%subdir
if @file(%%newfile)
if @greater(@file(%%subdir, T),@file(%%newfile, T))
rem file copy, @item(1, %x)\*.*, %%dest\%%subdir, showerrors
rem file copy, %%src\*.*, %%dest, showerrors
info Found same name files with newer dates - copying now
else
info No new files to copy
end
else
info New file found - copying now
rem file copy,@item(1, %x)\*.*, %%dest\%%subdir, showerrors
rem file copy, %%src\*.*, %%dest, showerrors
end
%x = @succ(%x)
until @equal(%x,@count(1))@greater(%x, @count(1))
%%REPORT = C:\ROOT.TXT
IF @FILE(%%REPORT)
FILE DELETE, %%REPORT
END
LIST SAVEFILE, 1, %%REPORT
RUN %%REPORT
list clear, 1
info Finished!
exit
|
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue May 20, 2003 5:35 am Post subject: |
|
|
Put something in PM for ya.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
|
|
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
|
|