topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 11:51 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: DONE: Rescue orphans  (Read 45886 times)

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
DONE: Rescue orphans
« on: June 16, 2006, 02:37 PM »
I have a download area that regularly ends up with "orphans" in folders/subdirs (subdirs with a single file) as their former companions are replaced elsewhere by newer or better versions. What I'd like to do is somehow automate going through a particular dir tree, and any files that are by themselves in their own folder are moved to their parent dir.

If that then creates another single-file dir, these would then be moved again to the next higher dir (either by running the program/script again or by the program/script checking for it). If anybody knows of something that already does this, please let me know.
:)
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?
« Last Edit: October 03, 2006, 09:16 PM by Cavalcader »

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #1 on: July 03, 2006, 02:50 PM »
The alternative concept is to match a filename pattern in a root directory with existing subdirs. Any takers? :)
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Rover

  • Master of Smilies
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 633
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #2 on: July 03, 2006, 06:27 PM »
I thought about this a little as a bat file and/or a pascal app. 
Do you really need this or are you just bored  :P
Insert Brilliant Sig line here

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #3 on: July 04, 2006, 10:51 AM »
Hi, Rover -- no, I've been hunting for this for quite some time now. :)  I've never found anything that will quite do it.

Here's a bit of background and discussion of the initial concept, but if you have a better idea I'm all, uh, eyes. 8)
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #4 on: July 11, 2006, 01:51 PM »
As this isn't a big solution, i didn't make a complete script out of it.
It should work, though.
(i hope you have autohotkey installed.)

PS: sorry for not having done this before, but i couldn't make recursive functions in ahk.

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #5 on: July 11, 2006, 03:30 PM »
(i hope you have autohotkey installed.)
Cool! No, no autohotkey yet, but that's easily fixable. I'll give it a shot! :Thmbsup:
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #6 on: July 12, 2006, 02:20 PM »
As this isn't a big solution, i didn't make a complete script out of it.
Thanks! Credits on the way -- it seems to work with some test files/dirs I made. I noticed a comment line saying
set the following line to "Loop, %Directory%\*, 0, 0"
if you'd like the script to not move a file when there is only one file on the folder, but there are any folders.
What should I set it to otherwise? I think it's probably ideal like it is now, but it's always good to know one's options. :)  I didn't see any prompt, although files were moved -- shouldn't I have?

What's involved in "complete script" status? A way to prompt for the path or something?
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?
« Last Edit: July 12, 2006, 02:26 PM by Cavalcader »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #7 on: July 12, 2006, 06:28 PM »
oops... typo. you should set it to
Loop, %Directory%\*, 1, 0
if you'd like it to behave like mentioned.
It's not a complete script because it doesn't prompt for anything (which makes it unuseful to compile), and i also noticed that it might not move one file it should. see the following tree:

Directory one
   Directory two
     Directory three
        file two
     file one
     
In this tree, file two is the only file on directory three, so, it's moved to directory two. but then, there are 2 files at directory two, which means they won't be moved to directory one, when they should be since originally there was only one file in each directory.
See what i mean?
Other than that, it's a pretty complete script :)

As for messages not displaying, might be because there's yet another typo. where is
Messages = true
should be
Messages := true

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #8 on: July 12, 2006, 08:15 PM »
oops... typo. you should set it to
Got it. Thanks!

and i also noticed that it might not move one file it should. see the following tree:

Directory one
   Directory two
   file one
     Directory three
     file two
I rearranged your tree to simplify what I understand you to be describing -- lemme know if I goofed somewhere.  8)

In this tree, file two is the only file on directory three, so, it's moved to directory two. but then, there are 2 files at directory two, which means they won't be moved to directory one, when they should be since originally there was only one file in each directory.
Hmm -- that actually would be counterproductive, at least for my concept. I look at it this way: putting a file in a dir adds organization to the file and whatever group it's a part of. Subdirs add more, but if those subdirs only have an orphan, it makes sense to move 'em to the parent. If there was already a file in the parent, then it must be related to the subdir file and it's fine that they're together. (Maybe others would do something different, but I think it makes perfect sense.) I think it's a first-rate script, especially for the first public version! :greenclp:

As for messages not displaying, might be because there's yet another typo.
Typo has been squashed -- thanks. :)  If you have time (or if not, maybe someone else does?) I'd love to work with someone to build a GUI on this puppy. I tend to be a very visual person, and I'll have an easier time using it that way.

Depending on your prefs, I can either send you my email address or we can hack it out in this topic. The latter might help others learn more about AutoHotkey, but (without looking) I bet there's already a thread on that topic. I'm doing math finals, which is why I'm kinda short on time to really dig into AHK right now.  :mrgreen:
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #9 on: July 13, 2006, 01:14 AM »
Had a minute to try it out after the recommended tweaks -- so far only one minor quibble. To use the tree style you used before, which seems to work well:

Dir A
  Dir B
    Dir C
    File C
File C gets moved properly to Dir B...
Dir A
  Dir B
  File C
    Dir C
...but then since Dir C is empty, file C should end up in Dir A. Does that add a lot of complexity?
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?
« Last Edit: July 13, 2006, 01:16 AM by Cavalcader »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #10 on: July 13, 2006, 03:14 AM »
Having it displaying something informing you about stome stuff shouldn't be a problem, i just can't do it right now (exams... bah!).
As for what you refered in your latest post, it wouldn't happen if you had it set to "Loop, %Directory%\*, 0, 0". If you have the '1' there, it'll see one file and one directory inside a directory and won't move it further down, since there is more than one element inside the dir.

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #11 on: July 13, 2006, 04:40 PM »
Having it displaying something informing you about stome stuff shouldn't be a problem, i just can't do it right now (exams... bah!).
No problem -- I understand completely. :)

As for what you refered in your latest post, it wouldn't happen if you had it set to "Loop, %Directory%\*, 0, 0".
Aha! Thanks -- I misunderstood when to use that instruction.
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #12 on: July 14, 2006, 02:52 PM »
It seems to work, but I'm still not seeing any dialogs. I posted what I have with the edits described above -- I'm not sure what's up.
:tellme:
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #13 on: August 04, 2006, 11:16 PM »
How goes it with the exams?   :deal:

My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #14 on: August 05, 2006, 05:06 AM »
 :-[  forgot this. thanks!
I'm now on vacations, i'll look into it asap.   8)

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #15 on: August 05, 2006, 05:48 PM »
Good deal! I hope you got good grades.  :)

Lemme know what I can do from this end...
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #16 on: August 21, 2006, 09:00 PM »
I'm now on vacations, i'll look into it asap.   8)
That sound we now hear in the background is the chirping of crickets far, far away.  :P
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #17 on: August 24, 2006, 04:59 PM »
I've added two lines.
#SingleInstance,Force
#NoTrayIcon
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #18 on: September 04, 2006, 05:48 PM »
'Kay, so methinks jgpaiva has gotten too busy to continue. Anybody else wanna help finish the script by adding a GUI?

Never mind -- false alarm.  :-[
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?
« Last Edit: September 05, 2006, 02:39 PM by Cavalcader »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #19 on: September 09, 2006, 12:46 PM »
Ok... At last an update!
Here is RescueOrphans v1.0.


RescueOrphans v1.0 updated 09-09-2006:
Retrieves single files lost in deep directories.
[Forum Topic][.ahk Version][.exe Version]

Features a full gui, about box, fixed confirmation dialogs, added a new option (delete folders, which deletes the folder from where the file was moved, if it's an empty folder) and lists the modifications.

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #20 on: September 09, 2006, 06:45 PM »
Here is RescueOrphans v1.0.
Wow, you've really been busy! Can't wait to check it out.
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #21 on: September 11, 2006, 04:19 PM »
New update... v1.001.
Hopefully, some bugs were fixed.


RescueOrphans v1.001 updated 11-09-2006:
Retrieves single files lost in deep directories.
[Forum Topic][.ahk Version][.exe Version]

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #22 on: September 12, 2006, 03:01 PM »
JG, first I gotta say...

Here's something we talked about earlier:
Dir A
  Dir B
    Dir C
    File C
File C gets moved properly to Dir B...
Dir A
  Dir B
  File C
    Dir C
...but then since Dir C is empty, file C should end up in Dir A. Does that add a lot of complexity?
That's since been addressed by the second checkbox in the GUI, I think -- but having it checked or unchecked doesn't seem to affect this scenario:

Dir A
    File A1
    File A2
    Dir B
        File B1
        Dir C
          File C1
          File C2
          File C3
        Dir D
          File D1
          File D2
          File D3
C & D are in B, and all are in A. What I'm running into is that B1 is moved to A regardless of the setting of the second checkbox. (Does that make sense? Let me know if I've explained it clearly.)

Regardless of such a trivial issue, like I said in a private note, you've done a first-rate job!
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #23 on: September 14, 2006, 04:50 AM »
Oops.. That was a bug.
Now fixed.. Please redownload:


RescueOrphans v1.002 updated 14-09-2006:
Retrieves single files lost in deep directories.
[Forum Topic][.ahk Version][.exe Version]

Cavalcader

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 194
  • Live Long & Prosper
    • View Profile
    • Donate to Member
Re: IDEA: Rescue orphans
« Reply #24 on: September 14, 2006, 12:09 PM »
Thank you, kind sir!  :D :up:
My Linguistic Profile:
  40% General American English
  30% Yankee
  20% Dixie

What Kind of American English Do You Speak?