topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday March 19, 2024, 2:01 am
  • 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

Author Topic: DONE: Delete folders within directory but not the files within the folder  (Read 27477 times)

FrothyAss

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
You know how some people package .zips/folders with even more useless folders within folders when all you want are the files within it without having to sift through seemingly endless amounts of folders? Yeah, I am tired of it, and would not mind a solution!

For example: 325647384694857462.jpg

^Sort of an over exaggeration, normally it would only be one extra unnecessary folder, but its an example, and dramatization sells ;)

My idea is of a "Delete Folder: Not Contents" sort of Windows Explorer shell right click context kind of option that deletes ONLY folders (not the files within the folders) for the selected directory I am currently in.



« Last Edit: February 10, 2013, 10:12 PM by FrothyAss »

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
You don't need to delete any folders.
You can:
(a) search for the file (and or its contents) that you want, and/or
(b) get a flat-file view of all the files in a set of nested folders.

All easily done in a decent Windows Explorer alternative - e.g., putting the flat file into a "scrap pane" in xplorer² (there's a free version).

By the way, I've seen PCs and file servers with exactly the sorts of deeply nested folders per your "dramatization" - including ones sparsely populated with documents.     :o

FrothyAss

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Searching does not rid the extra folders!

I also do not wish to have another file explorer, although I do like Total Commander.

I am looking for long term solutions to extra folders, besides the hassle of creating a new folder and moving files out of 'files nests' into the new folder. Its more for a perfectionist sort of mindset, having to go through unnecessary, or even possessing extra folders just bugs and flickers with my mind!

Mostly for organizational reasons, and preparations for torrents to be uploaded. I may be over-complicating the whole process, and please mind my greed, but that's the beauty of it all.

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Just to clarify, what do you think should happen when there are filename collisions?  Say in your example there is a "read.me" in every folder, as well as that one desired file way down deep - what should happen to all those read.mes?
vi vi vi - editor of the beast

FrothyAss

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Just to clarify, what do you think should happen when there are filename collisions?  Say in your example there is a "read.me" in every folder, as well as that one desired file way down deep - what should happen to all those read.mes?

Well, for my intended use, it would be for audio files, but i suppose an auto-rename feature (read.me, read(1).me, read(2).me) or renaming prompt could prevent issues, unless it is an app or program that requires the .me file 'AS IS' so perhaps a 'do not delete folder/continue anyways' prompt if conflict such as this occurs.

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
you should be able to find a solution in the coding snacks section.

others may be able to point you to specific threads, or search the forum as this functionality (or very near) has been requested several times :Thmbsup:

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Since you're already using Windows Explorer, you can simply use the find/search functionality to do what you want.  Press F3, enter *.* and do a quick search.  Then, just highlight all the found files and drag them into your top-level folder.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,640
    • View Profile
    • Donate to Member
Since you're already using Windows Explorer, you can simply use the find/search functionality to do what you want.  Press F3, enter *.* and do a quick search.  Then, just highlight all the found files and drag them into your top-level folder.

Are you saying I just wasted my time creating Move Everything Recursively, Delete Empty ?

MERDE!    ;D

Code: AutoIt [Select]
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=1360654278_56056.ico
  3. #AutoIt3Wrapper_UseUpx=n
  4. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  5. #cs ----------------------------------------------------------------------------
  6.  
  7.  AutoIt Version: 3.3.8.0
  8.  Author:         4wd
  9.  
  10.  Script Function:
  11.         Move Everything Recursively, Delete Empty (MERDE)
  12.  
  13. Icon from: http://www.iconfinder.com/icondetails/56056/32/crap_poo_shit_turd_icon
  14.  
  15. #ce ----------------------------------------------------------------------------
  16.  
  17. ; Script Start - Add your code below here
  18.  
  19. #include <RecFileListToArray.au3>
  20. #include <Array.au3>
  21.  
  22. If $CmdLine[0] = 0 Then Exit
  23. $srce = $CmdLine[1]
  24.  
  25. $files = _RecFileListToArray($srce, '*', 1, 1, 1, 2)
  26. If Not IsArray($files) Then
  27.         MsgBox(48, 'MERDE!', 'No files found!', 10)
  28.         Exit
  29.  
  30. _Valmorphanize($files, $srce)
  31.  
  32. $folders = _RecFileListToArray($srce, '*', 2, 1, 1, 2)
  33. If Not IsArray($folders) Then Exit
  34. _PruneEmpty($folders)
  35.  
  36.  
  37. Func _Valmorphanize($temp, $path)
  38.         For $i = 1 To $temp[0]
  39.                 If $path <> StringLeft($temp[$i], StringInStr($temp[$i], "\", 0, -1) - 1) Then
  40.                         $newdest = _AutoRename($path & '\' & StringRight($temp[$i], StringLen($temp[$i]) - StringInStr($temp[$i], "\", 0, -1)))
  41.                         FileMove($temp[$i], $newdest)
  42.                 EndIf
  43.         Next
  44.  
  45.  
  46. Func _PruneEmpty($temp)
  47.         For $i = 1 To $temp[0]
  48.                 If DirGetSize($temp[$i]) = 0 Then DirRemove($temp[$i], 1)
  49.         Next
  50.  
  51.  
  52. ; Function courtesy of KaFu:
  53. ; http://www.autoitscript.com/forum/topic/125602-filename-exists-auto-rename-making-too-many-duplicates/#entry871942
  54. Func _AutoRename($sFilename)
  55.         $sFilename_Buffer = $sFilename
  56.         $i = 1
  57.         While FileExists($sFilename)
  58.                 If $i = 1 Then
  59.                         $sFilename = StringLeft($sFilename_Buffer, StringInStr($sFilename_Buffer, "\", 0, -1)) & "Copy of " & StringRight($sFilename_Buffer, StringLen($sFilename_Buffer) - StringInStr($sFilename_Buffer, "\", 0, -1))
  60.                 Else
  61.                         $sFilename = StringLeft($sFilename_Buffer, StringInStr($sFilename_Buffer, "\", 0, -1)) & "Copy of (" & $i & ") " & StringRight($sFilename_Buffer, StringLen($sFilename_Buffer) - StringInStr($sFilename_Buffer, "\", 0, -1))
  62.                 EndIf
  63.                 $i += 1
  64.         WEnd
  65.         Return $sFilename

Put the executable in the %UserProfile%\SendTo directory and then you can just right-click->Send To MERDE.exe on the directory you want to turn to merde  :)

eg.

From this:

2013-02-12 12_46_47-R__test_ContourPlots.png

Do this:

2013-02-12 12_43_21-R__test.png

To get this:

2013-02-12 12_43_54-R__test_ContourPlots.png
« Last Edit: February 11, 2013, 11:37 PM by 4wd »

FrothyAss

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Thank you! Works perfectly, 4wd! Exactly what I needed.

For those with a problem with it (none yet, I am aware), put the unzipped files into a folder altogether, move the folder to desired location, and make a shortcut of the executable (MERDE.exe). Move the shortcut to SendTo folder, link below for how to get there.

For Windows 7 users, http://mintywhite.co...send-to-menu-how-to/

How do I move this topic to "Finished Programs"?

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Thank you! Works perfectly, 4wd! Exactly what I needed.

Nicely done, 4wd.   :Thmbsup:

For those with a problem with it (none yet, I am aware), put the unzipped files into a folder altogether, move the folder to desired location, and make a shortcut of the executable (MERDE.exe). Move the shortcut to SendTo folder, link below for how to get there.

May I suggest SendToSendTo?  =]  http://whyeye.org/projects/sendtosendto/

How do I move this topic to "Finished Programs"?

I take care of that.   :)

Elancore

  • Participant
  • Joined in 2013
  • *
  • Posts: 11
    • View Profile
    • Donate to Member
I used to have this problem before :)

Check this:
http://mike.geek-rep...om/software/suction/

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,640
    • View Profile
    • Donate to Member
Thank you! Works perfectly, 4wd! Exactly what I needed.

Nicely done, 4wd.   :Thmbsup:

Thanks skwire - I realised after I did it that all he wanted to do was flatten the directory structure.  ;D

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Posted across from another thread:
@nkormanik: Thanks for the info. - Moo0 RightClicker Pro 1.48 (Free to Try) looks rather nifty and seems to do some things for the right-click menu that I had not come across before.

@TucknDar: FileMenu Tools (Freeware) looks very interesting. In particular, I noticed that it includes this function:
  • Unpack Folder: Moves all the elements in the selected folders to the parent folder, and deletes these empty folders.

That could be useful as an alternative solution here: DONE: Delete folders within directory but not the files within the folder