TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cmwade77 on August 13, 2012, 05:39:39 PM

Title: Moving Folders
Post by: cmwade77 on August 13, 2012, 05:39:39 PM
Ok, I have a situation here, perhaps someone can help me, I have a lot of folders named Archive or Archived on my server that I need to move from that server to a drive on another server.

The paths need to remain the same, except for the drive letter (or server name). I have not yet found anything that allows this to be done.

I know this is not directly related to AutoCAD or LISP, but I know you guys might have something that works. I am open to this being done in LISP, VB.NET, Apple Script, Automator, a third party tool for Windows, Mac or Linux, basically whatever can get the job done.

I have tried writing my own; however, it turns out that some of the path names are too long for Windows (this was before we had a mixed environment too, so not sure how that happened) and so my toll would error out when that happens. I managed to get it to skip the errors; however, those folders need to be moved as well.
Title: Re: Moving Folders
Post by: Keith™ on August 13, 2012, 05:48:49 PM
Hmmm .. can you not simply drag and drop the entire folder structure from the source machine to the destination machine? If you do, the folders are automatically recreated in the same location as on the source.
Title: Re: Moving Folders
Post by: ronjonp on August 13, 2012, 05:54:39 PM
XCOPY  :-P
Title: Re: Moving Folders
Post by: cmwade77 on August 13, 2012, 05:59:37 PM
XCOPY  :-P
XCOPY doesn't seem to have a move option, nor a way to say I only want folders named Archive or Archived and all such folders.
Title: Re: Moving Folders
Post by: Lee Mac on August 13, 2012, 06:04:20 PM
IIRC vl-file-rename should work to move folders, though, I haven't tested it across drives... /disclaimer

EDIT: ignore the above, vl-file-rename can only rename the lowest folder in the directory tree.
Title: Re: Moving Folders
Post by: cmwade77 on August 13, 2012, 06:09:59 PM
Hmmm .. can you not simply drag and drop the entire folder structure from the source machine to the destination machine? If you do, the folders are automatically recreated in the same location as on the source.
Um, that would be a lot of folders, I want to move all Archive folders (and their contents) from we'll say Drive H: to Drive T: (or \\Server1 to \\Server2) with the remainder of the path remaining the same, so lets say that I have the following folder:
H:\Projects\Small Jobs\Archived

I would want that folder MOVED to:
T:\Projects\Small Jobs\Archived

IIRC vl-file-rename should work to move folders, though, I haven't tested it across drives... /disclaimer
I did look at that, but it doesn't seem to work across drives, but I will look again to see if I missed something.
Title: Re: Moving Folders
Post by: danallen on August 13, 2012, 06:12:20 PM
Try beyond compare by scooter software, has full function trial that will do what you need. You can filter by folder or file names, or any other attribute, date, etc.

http://www.scootersoftware.com/index.php (http://www.scootersoftware.com/index.php)

update - just to test the function, the filtering folder syntax is fussy, use "...\archive\" in the include folders dialog
Title: Re: Moving Folders
Post by: kruuger on August 13, 2012, 06:49:13 PM
Where is the problem  :-o
just drag all folders like Keith said.
of course need to wait until all files will be moved.
k.
Title: Re: Moving Folders
Post by: cmwade77 on August 13, 2012, 06:52:30 PM
Where is the problem  :-o
just drag all folders like Keith said.
of course need to wait until all files will be moved.
k.
Again, I do not want to move anything that is not in an Archive folder, so dragging and dropping does not work, as that would move everything.
Title: Re: Moving Folders
Post by: Kerry on August 13, 2012, 07:52:01 PM

Make a batch file
Code: [Select]
:: MOVESTUFF.BAT
:: kdub@theSwamp
:: MD "D:\Projects\Small Jobs\Archived\"
XCOPY /Y /E "K:\Projects\Small Jobs\Archived\*.*" "D:\Projects\Small Jobs\Archived\"
RD  /S /Q "K:\Projects\Small Jobs\Archived"
Title: Re: Moving Folders
Post by: cmwade77 on August 13, 2012, 07:53:54 PM

Make a batch file
Code: [Select]
:: MOVESTUFF.BAT
:: kdub@theSwamp
:: MD "D:\Projects\Small Jobs\Archived\"
XCOPY /Y /E "K:\Projects\Small Jobs\Archived\*.*" "D:\Projects\Small Jobs\Archived\"
RD  /S /Q "K:\Projects\Small Jobs\Archived"
Ok, but that was only an example, I also have Archived folders in probably around 350-400 subfolders (not just Small Jobs), this is where everything seems to fail.
Title: Re: Moving Folders
Post by: owenwengerd on August 13, 2012, 08:58:03 PM
This is exactly the type of scenario that ROBOCOPY was designed for.
Title: Re: Moving Folders
Post by: kruuger on August 14, 2012, 01:04:21 AM
This is exactly the type of scenario that ROBOCOPY was designed for.
x2

Code: [Select]
Robocopy.exe "H:\Projects\Small Jobs\Archived" "T:\Projects\Small Jobs\Archived" /E /V /NP /Z /R:0 /W:0 /XD "*Archive"
k.
Title: Re: Moving Folders
Post by: irneb on August 14, 2012, 08:48:34 AM
... it turns out that some of the path names are too long for Windows (this was before we had a mixed environment too, so not sure how that happened) ...
Could you explain what's going on? Also what systems are in this "mixed" environment.

AFAIK windows (if you use NTFS file systems - not one of the FAT based file systems) has no restriction on path length (or none that should matter). Some programs use old / custom libraries linking to Windows' file system (I think portions of acad falls into this category) - which might then error with path lengths are in excess of around 250 characters. That might thus propagate the error into AutoLisp - it's definitely not AutoLisp having a restriction on string lengths (I've tested this before and it works fine with strings up to around 200,000,000 characters).

If your "mixed" environment is linux servers, Mac's, NAS, etc. Then they may have some restrictions as well - also depending on the file system(s) they use. Note Linux & NAS (Network Attached Storage - usually using Linux/BSD as operating system) have a plethora of filesystems to choose from. You will have to make a decision if this is where your error occurs:
If you don't follow one or both those options, it won't only be your archiving which breaks apart.
Title: Re: Moving Folders
Post by: VovKa on August 14, 2012, 11:09:40 AM
why not use a file manager (FAR or alike)?
Title: Re: Moving Folders
Post by: irneb on August 14, 2012, 12:04:35 PM
why not use a file manager (FAR or alike)?
X2 for that one! It's like the old Norton Commander on steroids! On Linux I use Krusader (http://en.wikipedia.org/wiki/Krusader) ... much the same (only more of a GUI instead of text).

But methinks the OP's problem is he's got a set of folders like this:
Code: [Select]
X:\Project1
X:\Project1\Archive
X:\Project2
X:\Project2\Archive
X:\Project2\Area1
X:\Project2\Area1\Archive
X:\Project2\Area2
X:\Project2\Area3
X:\Project2\Area3\Archive
And then he wants to move those folders to another drive, yet keep all the same paths:
Code: [Select]
Z:\Project1\Archive
Z:\Project2\Archive
Z:\Project2\Area1\Archive
Z:\Project2\Area3\Archive
Omitting any paths which don't have Archive somewhere in their list of folders.

So it needs something which recreates full paths - just leaving the parent folders empty. And only moves the Archive folder (with its contents and subfolders) to the new drive.

IMO this sounds like a job for a bat/cmd script or as others have pointed out RoboCopy can do this for you.

What I'm a bit concerned about is the mention of path-names being too long. The above won't fix any of that.
Title: Re: Moving Folders
Post by: cmwade77 on August 14, 2012, 12:56:45 PM
This is exactly the type of scenario that ROBOCOPY was designed for.
x2

Code: [Select]
Robocopy.exe "H:\Projects\Small Jobs\Archived" "T:\Projects\Small Jobs\Archived" /E /V /NP /Z /R:0 /W:0 /XD "*Archive"
k.
Wouldn't this exclude any directories that have the word Archive within them?

But I think that pointed me in the right direction, I believe what I actually want is:
Code: [Select]
Robocopy.exe "\\befilesvr01\H Drive\Projects" "\\jtongson-pc\ARCHIVE2011\H Drive\Projects" archive* /move /E /NP /Z /R:0 /W:0