Moving a folder structure

Guys, We have a document management system where we can store emails, word docs etc against different Customers. The documents are stored on the server and we have a path to their locations. We have a new requirement to move the directory where these files are being saved. I’m testing the ‘Microsoft Scripting Runtime’.FileSystemObject automation and the moveFolder functions, but I keep getting a runtime error. The test code I’m using is as show: IF NOT (COPYSTR(FromPath, STRLEN(FromPath), 1) = ‘’) THEN FromPath += ‘’; IF NOT (COPYSTR(ToPath, STRLEN(ToPath), 1) = ‘’) THEN ToPath += ‘’; CREATE (“Au-ScriptFilesystem”); IF NOT “Au-ScriptFilesystem”.FolderExists(FromPath) THEN ERROR(‘The source folder does not exist’); “Au-ScriptFilesystem”.MoveFolder(FromPath, ToPath); //<- ERROR HERE Can anyone see what this isn’t working? The FromPath was ‘c:\a’ and the ToPath was ‘c:\b’ (trying to move a from the root to inside b) Thanks for your Time, Alex

QUOTE: IF NOT (COPYSTR(ToPath, STRLEN(ToPath), 1) = ‘’) THEN ToPath += ‘’; Take ‘c:\a’ StringLength = 5 You are trying to Copy from position 5 to 1 try IF NOT (COPYSTR(ToPath, STRLEN(ToPath)) = ‘’) THEN ToPath += ‘’;

The first arg is the starting position and the second arg is the number of place to copy. This bit of code it working fine, the issue is with the “Au-ScriptFilesystem”.MoveFolder(FromPath, ToPath) bit. But thanks for the input

Oops [:I] Both work ok. Does it work of if you hardcode the path’s ? Au-ScriptFilesystem".MoveFolder(‘C:\a’,‘c:\b’); //<- ERROR HERE This might be nothing but could it be the whitespace you are passing >||< Au-ScriptFilesystem".MoveFolder(FromPath, ToPath); //<- ERROR HERE Au-ScriptFilesystem".MoveFolder(FromPath,ToPath); //<- ERROR HERE

I’ve tried hard coding the paths instead of passing them, but with no joy. The space between args shouldn’t have an effect. I really dont get why its not working, the website: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthmovefolder.asp shows all functions with Filesystem. the aruments must be wrong.

Ahaa… Got it working with MoveFolder(‘c:\a’,‘c:\b’) Thanks anyway David

quote:


Originally posted by asnape
Ahaa… Got it working with MoveFolder(‘c:\a’,'c:\b')


Right, read the remarks: ----snip---- Remarks If source contains wildcards or destination ends with a path separator (), it is assumed that destination specifies an existing folder in which to move the matching files. Otherwise, destination is assumed to be the name of a destination folder to create. In either case, three things can happen when an individual folder is moved: If destination does not exist, the folder gets moved. This is the usual case. If destination is an existing file, an error occurs. If destination is a directory, an error occurs. ----snip----