Page 3 of 3 FirstFirst 123
Results 31 to 45 of 45
  1. #31
    Bronze Lounger
    Join Date
    Apr 2001
    Location
    Peterborough, Ontario, Canada
    Posts
    1,450
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Move to parent folder (XP Home SP2)

    I don't think you were misled, but they spent a lot on advertising.

    Unless I'm missing something in my interpretation of the problem, either of the programs offers an easy solution. Display two windows, tiled vertically with the same tree in each, and then select the parent in one pane and the file in the other pane. Copy or move the file from the one to the other. You can send it to the root or anywhere else in the tree if you want to. You can move files wholesale, using filters.

    If you had PC Tools you must have been able to do that at the time, since I think that sort of thing was the great attraction (and the reason I have been hooked on the successors). It is very convenient, easy to see, and after looking at those lines of code I'm glad I have an alternative.

  2. #32
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,892
    Thanks
    0
    Thanked 83 Times in 79 Posts

    Re: Move to parent folder (XP Home SP2)

    I've got to be honest: I don't really see your point. The programs you mention are compiled from far more lines of code than that! It's fairly simple to copy and paste that script into a text file, rename it and drop a shortcut into your Send To menu. Certainly as easy as installing a program and, I would guess, cheaper. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> It's not like you have to write this code out every time you want to use it.
    Regards,
    Rory
    Microsoft MVP - Excel.

  3. #33
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,766
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Move to parent folder (XP Home SP2)

    you don't even have to display 2 windows - it can be done with one with the left pane showing the folder structure and the right pane showing the folder where the files to be moved/copied reside. Then just drag and drop them. I think Hans pointed this out early in the thread. There are a few disadvantages to this approach though:
    - the left pane may be open to the search task or the files and folders task
    - the person dragging may not have a steady hand - I've seen lots of files end up in the folder above or below the one intended (or worse). It's a little easier to right click and be able to do the few additional clicks needed for the script approach.

    Thanks for the suggestions.

    Fred

  4. #34
    Bronze Lounger
    Join Date
    Apr 2001
    Location
    Peterborough, Ontario, Canada
    Posts
    1,450
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Move to parent folder (XP Home SP2)

    I said 'readers may already have programs that will do tricks', which means that anyone who already has such a program might take a look, not that they would dash out and purchase one for this express purpose. It's the same principle as Leif's 5-button Intellimouse Optical; I don't think he was telling anyone to go out and buy one.

  5. #35
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,766
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Move to parent folder (XP Home SP2)

    Steve, Rory

    In trying to decipher the code you and Rory provided (other than the fact that he provided the whole thing), it look like the main difference is in the error handling code within the for n loop. The two sets of code look pretty much the same to me. Of course, we all have our own style of writing. Any suggestions as to which way to go? I haven't tried either of them yet.

    Thanks guys.

    Fred

  6. #36
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,892
    Thanks
    0
    Thanked 83 Times in 79 Posts

    Re: Move to parent folder (XP Home SP2)

    Fred,
    The only real difference I think is down to the fact that the MoveFolder method does not have an overwrite option, and therefore the code needs to delete the existing folder first. One word of caution though: if the folder you are moving has the same name as the folder it is in (e.g. C:TestTest), Steve's code I think will error out because it deletes the folder that contains the folder you are trying to move, and hence deletes the folder you want moved. Not sure how much of an issue that is likely to be for you.
    Regards,
    Rory
    Microsoft MVP - Excel.

  7. #37
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,892
    Thanks
    0
    Thanked 83 Times in 79 Posts

    Re: Move to parent folder (XP Home SP2)

    Peter,
    I was not trying to cause offence - I admit my comment about cost was a bit of a facetious throwaway. My main point was that I don't really see the difference between using a program to achieve this, or using the code provided and hence I didn't really get your comment about gobbledygook. Your point about file management programs is well-founded, but, by the same token, one could use Explorer to do the same thing and Fred had already said he wanted something just a little bit more automatic. Apologies for any confusion caused.
    Regards,
    Rory
    Microsoft MVP - Excel.

  8. #38
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,766
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Move to parent folder (XP Home SP2)

    Hi Rory and Steve,

    Thanks for the enhancements. I had a chance this morning to try out the scripts with the error code. I wish I knew more about scripting code to try making more changes than the trivial ones I did. But here's where I'm at:

    1. With Rory's code, I didn't at first see the 2 lines at the bottom of the email saying with movefolder and movefile that you don't use the true false parameters and didn't notice this had been set to copyfile and copyfolder. So of course I got a copy when I thought I was getting a move. Then I changed copy... to move... and got the error msg about too many parameters. Then I deleted the true false. But then I don't understand what the IF...THEN...ELSE is doing since both parts have the same statement. It looks like I could also delete the ELSE part of this since, if the user answers NO not to overwrite, you don't want anything in the ELSE part (which is what Steve's Code does; I'm not sure what having a False on the statement does as opposed to just leaving the statement out entirely). Plugging ahead anyway, I got an error saying file already exists. So it looks like this code would need the Delete... method anyway for moving.

    2. If the above is true (Rory's code needs the Delete... method to work for move...), then there are less differences between the 2 sets of code. However, if Rory's observation about Steve's code is right about the Delete would delete C:Test and its subfolders (including the Test that you're trying to move up), it would seem to me that would be a problem with Rory's code if modified per #1. I do view the issue raised by Rory as a major problem. Although I don't usually name my files the same regardless of where they reside (all names are unique since my names usually describe the content), I'd hate for the one time that I don't follow my rules that the entire folder gets deleted.

    So I'm closer but holding steady for now.

    Fred

  9. #39
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,892
    Thanks
    0
    Thanked 83 Times in 79 Posts

    Re: Move to parent folder (XP Home SP2)

    Fred,
    There are various Ifs in there:
    1. Check if the object to be moved is a file or folder.
    2. Check if the object already exists in the target, if not, copy it
    3. If it does already exist, check if you want to overwrite, then either overwrite or do nothing.

    The italicised parts of 2 and 3 look much the same in code, but the copy in 3 is only triggered if there is a duplicate, whereas the copy in 2 occurs if there is not a duplicate. As the two are mutually exclusive, you need both (at least, as the function is written).

    When I get a chance I will rewrite the Move script to cope with the parent folder having the same name as the source (unless someone cares to beat me to it....)
    Regards,
    Rory
    Microsoft MVP - Excel.

  10. #40
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,766
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Move to parent folder (XP Home SP2)

    Steve and Rory,

    Thanks for all of your help. I haven't been able to get back to this since your last responses about a week ago. I noticed in Steve's latest post, based on the msgbox to handle the move manually, that it isn't so straightforward. For now, I think what I have is ok for the way I work (eg, file/folder names are never the same). I'll see if I can get back to this in the next few days.

    Fred

  11. #41
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Move to parent folder (XP Home SP2)

    Just to be sure I didn't cause any confusion: I took the "simple approach" in my last post primarily because I assumed (and I think maybe you'd indicated) that the name-conflict scenario would be a rare one -- and so handling the move manually would be fine, because it would only happen once in a great while.

    The complication to handling it with code, as I see it, is that you'd have to solicit more user input to find out if the user wants to (1) completely overwrite the existing folder (and all its contents), (2) add the contents of the "moved" folder to the existing folder, (3) rename the old folder, (4) move and rename the moved folder, or (5) forget the whole thing (at least for the moment) pending further pondering.

    Code could theoretically be written to do all that, but I think the user input options with VBScript are much more limited than with VB, so it might not be pretty. And in any event, it's probably not worth the bother if the name-conflict scenario doesn't happen very often.

  12. #42
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,766
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Move to parent folder (XP Home SP2)

    Steve,

    Totally agree about moving folders up - not worth the trouble. Being able to move/copy a file named x up to its parent where the parent already has an x is sufficient as long as there's some dialog to check about overwriting file x. As mentioned though, I rarely would create 2 files named x even if they're in different folders since my names reflect content. I just want to take a look at the last "finished" versions of moveup and copyup in light of the last set of comments you and Rory made about a week ago when I can get the chance. Things seem to be working fine as is so I think we're set even without the "manual move" code or I'll add that and call it a day.

    Fred

  13. #43
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Move to parent folder (XP Home SP2)

    Here's a simple approach. Substitute the following in place of my fso.DeleteFolder and fso.MoveFolder lines:
    <pre> If fdrCurrent.Name <> fdrCurrent.ParentFolder.Name Then
    fso.DeleteFolder strFolderName
    fso.MoveFolder strOldpath, strFolderName
    Else
    MsgBox("The folder that would be overwritten --" & vbCrLf & _
    " " & strFolderName & vbCrLf & _
    "-- is the parent folder of the selected folder (" & _
    fdrCurrent & ")." & vbCrLf & vbCrLf & _
    "Handle this move manually!")
    End If
    </pre>


  14. #44
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Move to parent folder (XP Home SP2)

    Note: I just corrected a pair of errors in the introductory sentence of <!post=post 562492,562492>post 562492<!/post>. The correct reference should be to "my fso.DeleteFolder and fso.MoveFolder lines", rather than "my fso.DeleteFile and fso.MoveFile lines" (which is how the post originally read).

  15. #45
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,766
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Move to parent folder (XP Home SP2)

    Thanks for letting me know. See, it was a good thing that I hadn't gotten around to looking at your last email.

    Fred

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •