WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: CadJoe on November 04, 2014, 03:18:29 PM

Title: Folder Move
Post by: CadJoe on November 04, 2014, 03:18:29 PM
Seems that this moves the entire Source Folder to the Destination Folder.

Is there a way to tweak it to only move the content of Source, directly into Destination ?


sourcedir = E:\Reports
targetdir = F:\Reports
;
FOF_CREATEPROGRESSDLG = 0 ;Create Progress dialog
oShell = ObjectCreate("Shell.Application")
oFolder = oShell.NameSpace(targetdir)
oFolder.MoveHere( sourcedir, FOF_CREATEPROGRESSDLG )
oShell = 0
;



E:\Reports\Folder 1, 2, 3, etc

Results in moving the entire e:\Reports folder into F:\Reports.

ie, F:\Reports\Reports\Folder 1, 2, 3,

and then deleting E:\Reports

I don't want to remove e:\reports, just subfolders and files.
and move them directly into the Destination Folder Reports.

Also, I can't just change Destination to F:\  instead of F:\Reports, as it has different ACL's from Source that can't change.

Running on Server 2012 R2.

Thanks,

CadJoe
WinBatch, Gotta Love It!
Title: Re: Folder Move
Post by: CadJoe on November 04, 2014, 09:41:11 PM
Ok, all fixed.

Might not be the correct way, but works.

I used DirItemize to get the sub folders, and then put oFolderMove inside For Loop, changing the source each time with Dest static.

I also changed FOF to value 16 to suppress Prompts.



For FOLDER_LOOP = 1 To DIR_COUNT
   ;
   CURR_DIR=ItemExtract(FOLDER_LOOP, FOLDER_LIST, @TAB)
   ;
   WinTitle("", CURR_DIR)
   ;
   sourcedir = (strcat(SOURCE_PATH,"\",CURR_DIR))
   ;
   ;
   FOF_CREATEPROGRESSDLG = 16 ; Suppress Prompt
   oShell = ObjectCreate("Shell.Application")
   oFolder = oShell.NameSpace(targetdir)
   oFolder.MoveHere( sourcedir, FOF_CREATEPROGRESSDLG )
   oShell = 0
   ;
   ;
NEXT FOLDER_LOOP


Works great now.

Thanks,

CadJoe
WinBatch, Gotta Love It!
Title: Re: Folder Move
Post by: td on November 05, 2014, 07:59:55 AM
You could always use the Shell Operations Extender's aFileCopy function.  But if you boat is floating, why change course?
Title: Re: Folder Move
Post by: snowsnowsnow on November 05, 2014, 08:31:14 AM
That might be a waterfall up ahead...
Title: Re: Folder Move
Post by: td on November 05, 2014, 12:40:43 PM
Worrywart.
Title: Re: Folder Move
Post by: snowsnowsnow on November 05, 2014, 04:38:55 PM
heh heh...