Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 45
  1. #16
    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 the tip. I think it was buried somewhere in the back of my brain. I work with my folder options set to open a folder in the same window; if I want a new window, I open one up explicitly. I changed the option just to see what would happen - works as you described. But I don't want to have an extra window open up just for copying/moving a file to its parent since I don't do this often (but often enough to be a bit of a pain).

    Fred

  2. #17
    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 Mark,

    Thanks for the info. This has potential since I often have several files to move back to the parent but getting a browse window for the first was not what I was hoping for.

    What I sometimes do is have a bunch of files in a folder that I have to process in some way (eg, open them, look for info, go onto the next file). Unfortunately, I sometimes get distracted and go off to another task. When I get back to the file processing task, I may forget which files I've dealt with. So what I do is make a subfolder that I move a file to when I'm done processing it. When I'm all done, there are no files left in the parent folder (or none that involved whatever processing). So now I want to move the files back from the subfolder to the parent. There are several ways to do this but none of them really are straightforward. Hence my original request to be able to move (usually not copy) a file back to its parent. Problem is that there are numerous files to be moved back. Otherwise, Rory's batch file solution would be pretty good.

    Fred

  3. #18
    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)

    Rory,

    Thanks for the original and the revision. In a reply to Mark, I indicated that your single-move was on the right track but I really needed multiple files. With the vb script, it looks like just what I wanted.

    So I put your script into a text file, saved the file to an arbitrary folder with a name like moveup.vbs, and put a shortcut to it in my Send To folder. I did a test and it worked fine. This is exactly what I needed. I also created a version for copying files to the parent by changing the next to last line.

    Is there a reason to put the scripts in some place and a shortcut to these files in the Send To - as opposed to just putting the script files in the Send To?

    Fred

  4. #19
    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)

    Jim,

    I think I'll pass on the command line. Rory's vb script seems just the bill. Thanks.

    Fred

  5. #20
    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)

    Doc,

    thanks for the help. I looked at the page and wasn't sure I saw what I wanted, but I decided to go with Rory's vb script.

    Fred

  6. #21
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,895
    Thanks
    0
    Thanked 85 Times in 81 Posts

    Re: Move to parent folder (XP Home SP2)

    Fred,
    To be honest, I never gave it any thought. Force of habit for me is to have all my little programming jobs in one location, so my natural inclination is to leave them there and copy shortcuts anywhere else they may be needed. It also means if I end up doing a reinstall, my scripts and stuff are all safe on their own separate partition.
    Regards,
    Rory
    Microsoft MVP - Excel.

  7. #22
    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)

    Rory,

    That's kind of what I thought. I just thought I'd ask but I ended up putting your script in a new folder named Scripts (am I clever) under my Program Files, which is on my D drive, and sticking the shortcut into Send To.

    Thanks.

    Fred

  8. #23
    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,

    I've been using the script for moving 1 or more files quite successfully - thanks.

    However, a problem came up today when I wanted to move a single folder up to its parent. The script crashed at Line 6. I'm not sure if that's the 6th line of the script or the 6th executable line. But looking at the code did not provide me with a clue as to what was wrong; needless to say, I would have no idea on how to fix it.

    Any chance I could impose to get a fix for this? No great rush on this. I can probably fix the copyup that I created once I see the fix for moveup.

    Thks.

    Fred

  9. #24
    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 Steve,

    Thanks for the fix. I made the changes to the scripts I created from Rory's code and they worked pretty well. Just a few quick things:

    1. As I read your instruction #2, I replaced the lines mentioned. The 9th line of code was the Next for the For n loop. Your replacement lines did not include a Next. So it bombed the first time thru. I added the Next back and it worked fine. I don't know if your post should be edited so that others will not run into the same issue as I did.

    2. The code works fine with a mixture of files and folders.

    3. I also changed my script that I modified from Rory's to provide the ability to copy files/folders to the parent folder. That worked well with one caveat - see #4.

    4. If a file or folder exists in the parent folder with the same name as what you're trying to move/copy up, the copy script silently overwrites the parent's version of the file/folder but the move script bombs with an appropriate message. While maybe some error trapping might be nice in the moveup script so the "duplicate" scenario appears more user friendly, I can live with it. However, it would be nice to get some error trapping so the copyup does not silently overwrite an item with the same name. If that's possible, then maybe the same error trapping could be applied to the moveup.

    As an FYI, the following is my version of copyup with your changes to Rory's original to allow files and folders to be copied up

    Dim fso, filCurrent, fdrCurrent
    Dim strOldPath, strFileName, strFolderName, n
    Set fso = createobject("Scripting.FileSystemObject")
    for n = 1 to wscript.arguments.count
    strOldPath = wscript.arguments(n - 1)
    If fso.FileExists(strOldPath) Then
    set filCurrent = fso.GetFile(strOldPath)
    strFileName = filCurrent.ParentFolder.ParentFolder & "" & filCurrent.Name
    fso.CopyFile strOldpath, strFileName
    Else
    set fdrCurrent = fso.GetFolder(strOldPath)
    strFolderName = fdrCurrent.ParentFolder.ParentFolder & "" & fdrCurrent.Name
    fso.CopyFolder strOldpath, strFolderName
    End If
    next

    Thanks.

    Fred

  10. #25
    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)

    I've semi-tested this code, but not as a script. Let me know if it works for you.

    1. Change the first & second lines of Rory's code to:

    Dim fso, filCurrent, fdrCurrent
    Dim strOldPath, strFileName, strFolderName, n

    2. Change the 6th-8th lines of Rory's code to:
    <pre>If fso.FileExists(strOldPath) Then
    set filCurrent = fso.GetFile(strOldPath)
    strFileName = filCurrent.ParentFolder.ParentFolder & "" & filCurrent.Name
    fso.MoveFile strOldpath, strFileName
    Else
    set fdrCurrent = fso.GetFolder(strOldPath)
    strFolderName = fdrCurrent.ParentFolder.ParentFolder & "" & fdrCurrent.Name
    fso.MoveFolder strOldpath, strFolderName
    End If</pre>


  11. #26
    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)

    Oops. I meant 6th-8th lines, and I've edited my previous post accordingly. (I was looking at 3 lines of code, and 6 + 3 = 9. Made sense to me at the time.)

    I may take a stab at the copy thing later, but hopefully Rory or another experienced scripter will step in first.

  12. #27
    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 an enhanced version of my substitution for the 6th-8th lines of Rory's code. If a file (or folder) with the same name already exists in the parent folder, this version asks you if you want to overwrite. (This applies to the "move" version, but you can easily adapt it so your "copy" script works the same way.)
    <pre> If fso.FileExists(strOldPath) Then
    set filCurrent = fso.GetFile(strOldPath)
    strFileName = filCurrent.ParentFolder.ParentFolder & "" & filCurrent.Name
    If fso.FileExists(strFileName) = False Then
    fso.MoveFile strOldpath, strFileName
    Else
    If MsgBox(strFileName & " already exists. Do you want to overwrite it?", _
    vbExclamation + vbYesNo) = vbYes Then
    fso.DeleteFile strFileName
    fso.MoveFile strOldpath, strFileName
    End If
    End If
    Else
    set fdrCurrent = fso.GetFolder(strOldPath)
    strFolderName = fdrCurrent.ParentFolder.ParentFolder & "" & fdrCurrent.Name
    If fso.FolderExists(strFolderName) = False Then
    fso.MoveFolder strOldpath, strFolderName
    Else
    If MsgBox(strFolderName & " already exists. Do you want to overwrite it?", _
    vbExclamation + vbYesNo) = vbYes Then
    fso.DeleteFolder strFolderName
    fso.MoveFolder strOldpath, strFolderName
    End If
    End If
    End If</pre>


  13. #28
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,895
    Thanks
    0
    Thanked 85 Times in 81 Posts

    Re: Move to parent folder (XP Home SP2)

    Hi Fred,
    Try something like:
    <pre>Dim fso, filCurrent, fdrCurrent
    Dim strOldPath, strFileName, strFolderName, n
    Set fso = createobject("Scripting.FileSystemObject")
    for n = 1 to wscript.arguments.count
    strOldPath = wscript.arguments(n - 1)
    If fso.FileExists(strOldPath) Then
    set filCurrent = fso.GetFile(strOldPath)
    strFileName = filCurrent.ParentFolder.ParentFolder & "" & filCurrent.Name
    if fso.FileExists(strFileName) then
    varReturn = msgbox("File already exists in parent. Overwrite it?",4,"Overwrite file?")
    if varreturn = 6 then
    fso.CopyFile strOldpath, strFileName, True
    end if
    else
    fso.CopyFile strOldpath, strFileName, false
    end if
    Else
    set fdrCurrent = fso.GetFolder(strOldPath)
    strFolderName = fdrCurrent.ParentFolder.ParentFolder & "" & fdrCurrent.Name
    if fso.FolderExists(strFolderName) then
    varReturn = msgbox("Folder already exists in parent. Overwrite it?",4,"Overwrite folder?")
    if varreturn = 6 then
    fso.CopyFolder strOldpath, strFolderName, True
    end if
    else
    fso.CopyFolder strOldpath, strFoldername, false
    end if
    End If
    next</pre>


    Note: for MoveFolder and MoveFile you do not use the True/False parameter.
    HTH
    Regards,
    Rory
    Microsoft MVP - Excel.

  14. #29
    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)

    For those of us who switched from DOS to Windows to avoid lines and lines of gobbledygook, there are alternatives.

    Some readers may already have programs that will do tricks they weren't aware of. LapLink will do file transfers from one machine to the same machine without even being connected to another machine, with all of the fancy file-transfer footwork that LapLink is capable of.

    I also have PowerDesk 6, which is generally thought of as an earlier-generation program. It is a descendant of Central Point's PC Tools for Windows (from an era when Central Point, or at least PC Tools, and Norton were competitors). Then Norton (or Symantec) bought out Central Point (or PC Tools), and changed the name of the application (which I can't remember at the moment) to Norton Navigator. Norton dropped that and VCom now has PowerDesk. Having used its predecessors I'm comfortable with the program, but I'm not sure how comfortable the program is with Windows in terms of performance and conflicts. It seemed a bit buggy for a time, but it performs better now that it has been patched, and it has a collection of powerful capabilities.

  15. #30
    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)

    You switched from DOS to Windows to avoid gobbledygook? I switched because I thought I didn't really have a choice. Was I misled?

    Speaking as one of Central Point Software's biggest fans (I still miss PCTools), I feel compelled to note that, unless LapLink or PowerDesk has a "Move to Parent" command, Fred's still pretty much stuck in Gobbledygook Gulch, isn't he?

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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