Author Topic: Year End Clean up  (Read 1883 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 641
Year End Clean up
« on: January 03, 2005, 05:07:39 PM »
Greetings!

I have a 40GB external hard drive for yearly back ups.

The directory tree looks like this:

Code: [Select]
f:/
f:/2001/
f:/2001/acad/
f:/2001/acad/ut/

f:/2002/
f:/2002/acad/
f:/2002/acad/ut/

f:/2003
f:/2003/acad/
f:/2003/acad/ut/


Maybe 4,000 or so directories.

I am trying to write a call to make a single list of strings that includes each directory name ( complete with drive:/directory/subdirect ).  A full tree for file comparisions.

Recurstion using McNeels Dos_subdir is crapping out on me.

So far:

Code: [Select]


(defun dos_asd (p)
  (foreach f (dos_subdir p)
    (setq l (cons (strcase (strcat p f)) l))
    (if (dos_subdir (strcat p f "/"))
        (dos_asd (strcat p f "/")))
    (princ "#")
        )
l)


Using a call of:
Code: [Select]

(dos_asd "f:/")


Has anyone seen a full path/tree function around? ( DOS 8.3 preferably ) but I can deal with most anything

The end result is to delete duplicate files on the back up drive.  If the file hasn't changed since 2001, delete the copies in 2002, 2003. etc.  But keep the older ones if has been edited.

TIA  -David[/code]
R12 Dos - A2K

whdjr

  • Guest
Year End Clean up
« Reply #1 on: January 03, 2005, 05:45:32 PM »
David,

Try this on any folder and it should give you a list of all the files in that folder and all subfolders.  You can change the file type by changing the "*.*" to whatever extension you need.  This tool uses the expresstools (R2000 (acet-ui-pickdir)) to select the start folder.  If this is a problem then you will have to come up with another solution.

I haven't tried it on the magnitude of files you are using so it may crap out as well.  Just try it and see.

Code: [Select]
(defun *list_folders* (path)
  (defun get_folders (folder / f)
    (mapcar '(lambda (x)
      (cons (setq f (strcat folder "\\" x))
    (apply 'append (get_folders f))
      )
    )
   (cddr (vl-directory-files folder nil -1))
    )
  )
  (cons path (apply 'append (get_folders path)))
)

(defun get_dwgs (path ext)
  (mapcar '(lambda (x)
    (mapcar '(lambda (y)
(strcat x "\\" y)
     )
    (vl-directory-files x ext 1)
    )
  )
 path
  )
)

(defun c:all_files ()
  (apply 'append
(get_dwgs (*list_folders* (acet-ui-pickdir)) "*.*")
  )
)


Hope this helps,

Jeff_M

  • King Gator
  • Posts: 3948
  • C3D user & customizer
Re: Year End Clean up
« Reply #2 on: January 03, 2005, 06:30:24 PM »
Quote from: David D Bethel
Greetings!

I have a 40GB external hard drive for yearly back ups.

The directory tree looks like this:

Code: [Select]
f:/
f:/2001/
f:/2001/acad/
f:/2001/acad/ut/

f:/2002/
f:/2002/acad/
f:/2002/acad/ut/

f:/2003
f:/2003/acad/
f:/2003/acad/ut/


TIA  -David[/code]


Well, here's my stab at the directory tree portion. It returns a list of the directories and their subs that you can run for the files you want to check.
I tested it on a directory tree that is 4.6 GB, 39,000+ files and 198 directories. (Although in hind site, since I'm only returning the directories it really isn't that big.......so I just re-ran it on my C:, returned a list of 6210 directories in about 2 minutes)
Code: [Select]

(defun vl-dir-tree (p)
  (foreach f (vl-directory-files p nil -1)
    (if (not (or (eq f ".")
(eq f "..")
)
    )
      (progn
(vl-dir-tree (strcat p "\\" f))
(setq tree (cons (strcat p "\\" f) tree))
)
      )
    )
  )
;;sample use below
(setq tree nil)
(setq tree (vl-sort (vl-dir-tree "C:\\Base Maps") '<))

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16727
  • Superior Stupidity at its best
Year End Clean up
« Reply #3 on: January 03, 2005, 08:47:32 PM »
If you can make simple DOS calls, this will return all of the directories from a given starting location .......

Code: [Select]

DIR /AD /S /B Drive:\Path > C:\Directories.txt


For example if you wanted all of the directories under drive C: you would do:
Code: [Select]

DIR /AD /S /B C:\ > C:\Directories.txt


If you wanted the information only in the C:\Windows folder
Code: [Select]

DIR /AD /S /B C:\Windows > C:\Directories.txt


Alternatively you can use that in a batch file and just call it.

I processed a 40GB drive returned over 4000 directories in under 1 1/2 minutes.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Mark

  • Custom Title
  • Seagull
  • Posts: 28683
Year End Clean up
« Reply #4 on: January 04, 2005, 07:09:12 AM »
TheSwamp.org  (serving the CAD community since 2003)

Ron Heigh

  • Guest
Year End Clean up
« Reply #5 on: January 04, 2005, 08:37:17 AM »
Have you looked at Windows Commander?
It will print you a list of your directory tree.

David Bethel

  • Swamp Rat
  • Posts: 641
Year End Clean up
« Reply #6 on: January 04, 2005, 08:53:29 AM »
Keith,

The bat file and DIR command worked great.  

I will have to digest the rest as I haven't used any VL commands.  As usual, I try and accomplish most of my file mantiance from with plain AutoLisp.

Thanks!  -David
R12 Dos - A2K